From 569f0269e3adcf873fc3cf0fb315b409065c2d4c Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Tue, 20 Dec 2022 02:20:16 +0200 Subject: [PATCH] print debugging for reddit mentions --- files/helpers/offsitementions.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/files/helpers/offsitementions.py b/files/helpers/offsitementions.py index e1c6f57dbf..0f2849c8ee 100644 --- a/files/helpers/offsitementions.py +++ b/files/helpers/offsitementions.py @@ -21,6 +21,7 @@ from files.classes.notifications import Notification # value from /meta (or just guessing) and doing a random selection of keywords. def offsite_mentions_task(cache:Cache): + print('hola', flush=True) site_mentions = get_mentions(cache, const.REDDIT_NOTIFS_SITE) notify_mentions(site_mentions) @@ -32,6 +33,7 @@ def offsite_mentions_task(cache:Cache): g.db.commit() # commit early otherwise localhost testing fails to commit def get_mentions(cache:Cache, queries:Iterable[str], reddit_notifs_users=False): + print('nword', flush=True) kinds = ['submission', 'comment'] mentions = [] exclude_subreddits = ['PokemonGoRaids', 'SubSimulatorGPT2', 'SubSimGPT2Interactive'] @@ -43,13 +45,15 @@ def get_mentions(cache:Cache, queries:Iterable[str], reddit_notifs_users=False): size = 1 if reddit_notifs_users else 100 for kind in kinds: try: + print('request', flush=True) data = requests.get(( f'https://api.pushshift.io/reddit/{kind}/search?html_decode=true' f'&q={"%7C".join(queries)}' f'&subreddit=!{",!".join(exclude_subreddits)}' f'&after={after}' f'&size={size}'), timeout=15).json()['data'] - except: + except Exception as e: + print(e, flush=True) continue for thing in data: @@ -83,7 +87,9 @@ def get_mentions(cache:Cache, queries:Iterable[str], reddit_notifs_users=False): return mentions def notify_mentions(mentions, send_to=None, mention_str='site mention'): + print('notify_mentions', flush=True) for m in mentions: + print(m, flush=True) author = m['author'] permalink = m['permalink'] text = sanitize(m['text'], golden=False) @@ -109,6 +115,7 @@ def notify_mentions(mentions, send_to=None, mention_str='site mention'): distinguish_level=6) g.db.add(new_comment) g.db.flush() + print(new_comment.id, flush=True) new_comment.top_comment_id = new_comment.id if send_to: