Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 23 additions & 8 deletions cfbot.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -41,18 +38,36 @@ 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)

# build one patch, if it is time for that
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)
Expand Down
20 changes: 20 additions & 0 deletions cfbot_commitfest_rpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import cfbot_config
import cfbot_util
import html
import json

# from html.parser import HTMLParser
import re
Expand Down Expand Up @@ -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))
Expand Down
23 changes: 9 additions & 14 deletions cfbot_web.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,26 +240,20 @@ 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",
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,
Expand Down Expand Up @@ -333,8 +327,9 @@ def build_page(
<body>
<h1>PostgreSQL Patch Tester</h1>
<p>
<a href="index.html">Current commitfest</a> |
<a href="next.html">Next commitfest</a> |
<a href="inprogress.html">In Progress commitfest</a> |
<a href="open.html">Open commitfest</a> |
<a href="draft.html">Draft commitfest</a> |
<a href="https://wiki.postgresql.org/wiki/Cfbot">FAQ</a> |
<a href="statistics.html">Statistics</a> |
<a href="highlights/all.html">Highlights</a>
Expand Down