mirror of
https://github.com/wassname/psaw.git
synced 2026-09-09 11:30:51 +08:00
Added aggs support to _search
This commit is contained in:
@@ -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.
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user