diff --git a/CHANGES.rst b/CHANGES.rst index 9a7a750..31bc5fa 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -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. diff --git a/psaw/PushshiftAPI.py b/psaw/PushshiftAPI.py index 1e26b80..8aa1465 100644 --- a/psaw/PushshiftAPI.py +++ b/psaw/PushshiftAPI.py @@ -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