Skip to content

Commit

Permalink
feat: joj3-check-env add title
Browse files Browse the repository at this point in the history
  • Loading branch information
BoYanZh committed Feb 1, 2025
1 parent da37d09 commit 111526b
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions joint_teapot/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -863,7 +863,7 @@ def joj3_check_env(
repo: Repo = tea.pot.git.get_repo(grading_repo_name)
now = datetime.now()
items = group_config.split(",")
msg = ""
comment = ""
failed = False
for item in items:
name, values = item.split("=")
Expand All @@ -875,8 +875,8 @@ def joj3_check_env(
submit_count = 0
commits = repo.iter_commits(paths=scoreboard_file_name, since=since_git_format)
for commit in commits:
msg = commit.message.strip()
lines = msg.splitlines()
comment = commit.message.strip()
lines = comment.splitlines()
pattern = (
r"joj3: update scoreboard for (?P<exercise_name>.+?) "
r"by @(?P<submitter>.+) in "
Expand Down Expand Up @@ -906,22 +906,27 @@ def joj3_check_env(
)
use_group = False
if name:
msg += f"keyword `{name}` "
comment += f"keyword `{name}` "
else:
use_group = True
for group in groups or "":
if group.lower() == name.lower():
use_group = True
break
msg += (
comment += (
f"in last {time_period} hour(s): "
f"submit count {submit_count}, "
f"max count {max_count}"
)
if use_group and submit_count + 1 > max_count:
failed = True
msg += ", exceeded"
msg += "\n"
comment += ", exceeded"
comment += "\n"
if failed:
title = "### Submission Count Check Failed:"
else:
title = "### Submission Count Check Result:"
msg = f"{title}\n{comment}\n"
print(json.dumps({"msg": msg, "failed": failed})) # print result to stdout for joj3


Expand Down

0 comments on commit 111526b

Please sign in to comment.