From 0ee5627298c3ca66b48ab0edcafaa0db647f2a49 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Jul 28 2020 13:00:50 +0000 Subject: When querying the list of packages maintained by people, also query dist-git itself So far we only relied on the pagure_bz.json file to tell us what someone was involved with. However, if someone set their watch status to "unwatch" on a package, that package will not show up in pagure_bz.json. So we'll now be querying both that file and dist-git itelf directly. Signed-off-by: Pierre-Yves Chibon --- diff --git a/scripts/distgit/retire_packagers.py b/scripts/distgit/retire_packagers.py index 4a3dcea..fa02af1 100644 --- a/scripts/distgit/retire_packagers.py +++ b/scripts/distgit/retire_packagers.py @@ -253,19 +253,41 @@ def main(args): _log.debug("Loading usernames for the CLI arguments") usernames = args.usernames + # We load the info from the pagure_bz file which will tell us everything + # that would be synced to bugzilla (POC and CC) _log.debug("Loading info from dist-git's pagure_bz.json file") session = retry_session() req = session.get(f"{dist_git_base}/extras/pagure_bz.json") pagure_bz = req.json() session.close() - packages_per_user = collections.defaultdict(list) + packages_per_user = collections.defaultdict(set) for namespace in pagure_bz: for package in pagure_bz[namespace]: _log.debug("Processing %s/%s", namespace, package) for user in pagure_bz[namespace][package]: if user in usernames: - packages_per_user[user].append(f"{namespace}/{package}") + packages_per_user[user].add(f"{namespace}/{package}") + + # On the top of this, we'll also query the list from dist-git directly as + # the previous source of info while quicker to query will not include + # the packages that the packagers have access to but set their watch status + # to "unwatch". + for username in sorted(usernames): + _log.debug("Loading info from dist-git's %s's page", username) + url = f"{dist_git_base}/api/0/user/{username}?per_page=50" + while url: + req = session.get(url) + data = req.json() + for repo in data["repos"]: + maintainers = set(repo["user"]["name"]) + for acl in repo["access_users"]: + maintainers.update(set(repo["access_users"][acl])) + if username in maintainers: + namespace = repo["namespace"] + package = repo["name"] + packages_per_user[username].add(f"{namespace}/{package}") + url = data["repos_pagination"]["next"] for username in sorted(usernames): _log.debug("Processing user: %s", username)