make offsite_mentions_task take 3 seconds instead of 14 seconds

pull/199/head
Aevann 2023-09-14 20:36:10 +03:00
parent b029ae2c38
commit 112841cf9e
1 changed files with 5 additions and 7 deletions

View File

@ -32,13 +32,11 @@ def offsite_mentions_task(cache):
def get_mentions(cache, queries, reddit_notifs_users=False):
mentions = []
for kind in ('submission', 'comment'):
data = []
for query in queries:
url = f'https://api.pullpush.io/reddit/search/{kind}?q={query}'
try: req = requests.get(url, headers=HEADERS, timeout=5, proxies=proxies)
except: return []
data += req.json()['data']
q = " or ".join(queries)
url = f'https://api.pullpush.io/reddit/search/{kind}?q={q}'
try: req = requests.get(url, headers=HEADERS, timeout=5, proxies=proxies)
except: return []
data = req.json()['data']
for thing in data:
if not thing.get('permalink'):