Added aggs support to _search

This commit is contained in:
David Marx
2018-08-06 01:16:01 -07:00
parent a110db8a37
commit 4e7731f3a4
2 changed files with 14 additions and 1 deletions
+8
View File
@@ -1,6 +1,14 @@
Change Log
==========
x.x.x (????/??/??)
------------------
* Fixed (added?) `aggs` support.
* If an aggs parameter is provided to a search method, it will be returned as the first result.
* Subsequent results will be yielded as though there was no aggs parameter.
* To the best of my understanding, PushShift only returns 100 results per agg, and there is not
way to page for additional results.
0.0.5 (2018/08/05)
------------------
* New parameter documentation added to README.
+6 -1
View File
@@ -178,8 +178,13 @@ class PushshiftAPIMinimal(object):
self.payload = copy.deepcopy(kwargs)
endpoint = 'reddit/{}/search'.format(kind)
url = self.base_url.format(endpoint=endpoint)
for response in self._handle_paging(url):
if 'aggs' in response:
yield response['aggs']
# Aggs responses are unreliable in subsequent batches with
# current search paging implementation. Enforce aggs result
# is only returned once.
self.payload.pop('aggs')
results = response['data']
if len(results) == 0:
return