From 1f985f0feb4761c9fd3fcc871a99787539cda434 Mon Sep 17 00:00:00 2001 From: Mattia Verga Date: May 02 2023 15:40:12 +0000 Subject: Add check on Fedora Discussion Signed-off-by: Mattia Verga --- diff --git a/README.md b/README.md index d45d816..df88f43 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,7 @@ The script will search for any activity in the last year in: - pagure.io - bodhi (through datagrepper) - Fedora mailing lists +- Fedora Discussion - Red Hat bugzilla The step-one subcommand will output the 'inactive_packagers.csv' file with a list of all users diff --git a/find_inactive_packagers.py b/find_inactive_packagers.py index 360e5b7..4311161 100644 --- a/find_inactive_packagers.py +++ b/find_inactive_packagers.py @@ -31,6 +31,7 @@ The script will search for any activity in the last year in: - pagure.io - bodhi (through datagrepper) - Fedora mailing lists +- Fedora Discussion - Red Hat bugzilla The step-one subcommand will output the 'inactive_packagers.csv' file with a list of all users @@ -285,6 +286,28 @@ def _check_maillists_activity(fasclient, user, delta=365): return (False, emails) +def _check_discourse_activity(user, delta=365): + """Look for user recent activity in Fedora Discussion.""" + if not user: + log.error('ERROR: Cannot check an empty username!') + return False + try: + # I cannot find any documentation, but action types 4 and 5 should mean user posting to + # a new thread or replying to existing thread + r = session.get(f'https://discussion.fedoraproject.org/user_actions.json?username={user}&filter=4,5&limit=1').json() + if r.get('errors', None) or not r.get('user_actions', []): + return False + last_user_action_date = datetime.fromisoformat(r.get('user_actions')[0]['created_at'].replace('Z', '+00:00')) + time_delta = datetime.now(timezone.utc) - last_user_action_date + if time_delta.days <= delta: + log.info(f'Found recent post from user {user}: {last_user_action_date}.') + return True + except Exception: + log.error(f'ERROR: Error while retrieving Fedora Discussion activity for user {user}.') + return False + return False + + def _check_bugzilla_activity(bzclient, packager, check_fedora_alias=True, privacy=False, delta=365): """Look for user recent activity in Bugzilla. @@ -368,6 +391,9 @@ def _check_user_activity(user, privacy=False, fasclient=None, bzclient=None): pagure = False if src_fpo or pagure: return True + log.info(f'Checking {user} activity in Fedora Discussion...') + if _check_discourse_activity(user): + return True log.info(f'Checking {user} activity in Bodhi...') if _check_bodhi_activity(user): return True @@ -498,6 +524,16 @@ def step_one(ctx, with_bz_check, open_tickets): log.info(f'### Found {len(inactive_packagers)} users with no activity in pagure/src.fp.org over the last year. ###') + # Check for recent posts in Fedora Discussion + log.info('Checking users activity in Fedora Discussion...') + for i, p in enumerate(copy(inactive_packagers)): + if i > 0 and i % 100 == 0: + log.info(f'Done {i}.') + if _check_discourse_activity(p): + inactive_packagers.remove(p) + + log.info(f'### Found {len(inactive_packagers)} users which didn\'t post any message in Fedora Discussion over the last year. ###') + # Check for activity in Bodhi through datagrepper messages log.info('Checking users activity in Bodhi...') for i, p in enumerate(copy(inactive_packagers)):