From b0f6e81ccc305ed706c17348a1b3a3a5e1076d6f Mon Sep 17 00:00:00 2001 From: Aevann Date: Mon, 11 Sep 2023 20:55:46 +0300 Subject: [PATCH] restore offsite_mentions_task for normal every-5-minute usage --- files/helpers/offsitementions.py | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/files/helpers/offsitementions.py b/files/helpers/offsitementions.py index 0940cfcaf..f8ad8bd17 100644 --- a/files/helpers/offsitementions.py +++ b/files/helpers/offsitementions.py @@ -38,14 +38,8 @@ def get_mentions(cache, queries, reddit_notifs_users=False): data = [] for query in queries: - last_processed = 9999999999 - while True: - url = f'https://api.pullpush.io/reddit/search/{kind}?q={query}&before={last_processed}' - new_data = requests.get(url, headers=HEADERS, timeout=5, proxies=proxies).json()['data'] - data += new_data - try: last_processed = int(new_data[-1]['created_utc']) - except: break - if last_processed < 1682872206 or len(new_data) < 100: break + url = f'https://api.pullpush.io/reddit/search/{kind}?q={query}' + data += requests.get(url, headers=HEADERS, timeout=5, proxies=proxies).json()['data'] data = sorted(data, key=lambda x: x['created_utc'], reverse=True) @@ -94,7 +88,7 @@ def notify_mentions(mentions, send_to=None, mention_str='site mention'): author_id=const.AUTOJANNY_ID, parent_post=None, body_html=notif_text).one_or_none() - if existing_comment: continue + if existing_comment: break new_comment = Comment( author_id=const.AUTOJANNY_ID,