From 130c4f33c9cdb48cb55ecc4a31bccea2e560f5ed Mon Sep 17 00:00:00 2001 From: CDeLeon94 <18326238+CDeLeon94@users.noreply.github.com> Date: Tue, 3 Aug 2021 21:42:35 -0700 Subject: [PATCH] Set 'sort' based on use of 'before' or 'after' This gives the most intuitive results, and brings the code in line with documentation that already exists. --- psaw/PushshiftAPI.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/psaw/PushshiftAPI.py b/psaw/PushshiftAPI.py index 8699e6c..a21699b 100644 --- a/psaw/PushshiftAPI.py +++ b/psaw/PushshiftAPI.py @@ -161,7 +161,10 @@ def _add_nec_args(self, payload): payload['metadata'] = 'true' if 'sort' not in payload: # Getting weird results if this is not made explicit. Unclear why. - payload['sort'] = 'desc' + if 'after' in payload: + payload['sort'] = 'asc' + else: + payload['sort'] = 'desc' if 'filter' in payload: #and payload.get('created_utc', None) is None: if not isinstance(payload['filter'], list): if isinstance(payload['filter'], str):