From 6dba6ccf8e8344c2388f211c7740a984d064875f Mon Sep 17 00:00:00 2001 From: "David G. Johnston" Date: Mon, 14 Apr 2025 15:16:10 -0700 Subject: [PATCH] Use CFApp /api/v1/commitfest/active endpoint to find CFIds --- cfbot.py | 31 +++++++++++++++++++++++-------- cfbot_commitfest_rpc.py | 20 ++++++++++++++++++++ cfbot_web.py | 23 +++++++++-------------- 3 files changed, 52 insertions(+), 22 deletions(-) diff --git a/cfbot.py b/cfbot.py index e347f95..b4f0afe 100755 --- a/cfbot.py +++ b/cfbot.py @@ -30,9 +30,6 @@ def try_lock(): def run(): with cfbot_util.db() as conn: - # get the current Commitfest ID - commitfest_id = cfbot_commitfest_rpc.get_current_commitfest_id() - # pull in any build results that we are waiting for # XXX would need to aggregate the 'keep_polling' flag if we went # back to supporting multiple providers, or do something smarter, @@ -41,10 +38,23 @@ def run(): cfbot_cirrus.pull_build_results(conn) # exchange data with the Commitfest app - logging.info("pulling submissions for current commitfest") - cfbot_commitfest.pull_submissions(conn, commitfest_id) - logging.info("pulling submissions for next commitfest") - cfbot_commitfest.pull_submissions(conn, commitfest_id + 1) + + workflow = cfbot_commitfest_rpc.get_commitfest_workflow() + for bucket in ["open", "inprogress", "parked"]: + if workflow[bucket]["id"]: + cfid = workflow[bucket]["id"] + logging.info( + "pulling submissions for %s commitfest %d" % (bucket, cfid) + ) + cfbot_commitfest.pull_submissions(conn, cfid) + + if workflow["inprogress"]["id"]: + commitfest_id = workflow["inprogress"]["id"] + else: + # An open commitfest is supposed to exist at all times. + commitfest_id = workflow["open"]["id"] + + # scrape thread data logging.info("pulling modified threads") cfbot_commitfest.pull_modified_threads(conn) @@ -52,7 +62,12 @@ def run(): cfbot_patch.maybe_process_one(conn, commitfest_id) # rebuild a new set of web pages - cfbot_web.rebuild(conn, commitfest_id) + submissions = cfbot_web.load_submissions(conn, commitfest_id) + for bucket in ["open", "inprogress", "parked"]: + if workflow[bucket]["id"]: + cfid = workflow[bucket]["id"] + cfbot_web.rebuild(conn, cfid, bucket, submissions) + cfbot_web.rebuild_authors(conn, submissions) # garbage collect old build results cfbot_util.gc(conn) diff --git a/cfbot_commitfest_rpc.py b/cfbot_commitfest_rpc.py index 75ec3a4..63e32b8 100644 --- a/cfbot_commitfest_rpc.py +++ b/cfbot_commitfest_rpc.py @@ -6,6 +6,7 @@ import cfbot_config import cfbot_util import html +import json # from html.parser import HTMLParser import re @@ -190,6 +191,25 @@ def get_current_commitfest_id(): return result +def get_commitfest_workflow(): + result = cfbot_util.slow_fetch( + cfbot_config.COMMITFEST_HOST + "/api/v1/commitfest/active" + ) + jsonobj = json.loads(result) + workflow = jsonobj["workflow"] + + if not workflow["open"]: + workflow["open"]["id"] = None + + if not workflow["inprogress"]: + workflow["inprogress"]["id"] = None + + if not workflow["parked"]: + workflow["parked"]["id"] = None + + return workflow + + if __name__ == "__main__": for sub in get_submissions_for_commitfest(get_current_commitfest_id()): print(str(sub)) diff --git a/cfbot_web.py b/cfbot_web.py index 25a78a4..8264584 100755 --- a/cfbot_web.py +++ b/cfbot_web.py @@ -240,8 +240,7 @@ def load_submissions(conn, commitfest_id): return results -def rebuild(conn, commitfest_id): - submissions = load_submissions(conn, commitfest_id) +def rebuild(conn, commitfest_id, commitfest_name, submissions): build_page( conn, "x", @@ -249,17 +248,12 @@ def rebuild(conn, commitfest_id): submissions, None, None, - os.path.join(cfbot_config.WEB_ROOT, "index.html"), - ) - build_page( - conn, - "x", - commitfest_id + 1, - submissions, - None, - None, - os.path.join(cfbot_config.WEB_ROOT, "next.html"), + os.path.join(cfbot_config.WEB_ROOT, commitfest_name, ".html"), ) + return submissions + + +def rebuild_authors(conn, submissions): for author in unique_authors(submissions): build_page( conn, @@ -333,8 +327,9 @@ def build_page(

PostgreSQL Patch Tester

- Current commitfest | - Next commitfest | + In Progress commitfest | + Open commitfest | + Draft commitfest | FAQ | Statistics | Highlights