feat: joj3-check-env add title
This commit is contained in:
parent
da37d09e23
commit
111526bac3
|
@ -863,7 +863,7 @@ def joj3_check_env(
|
||||||
repo: Repo = tea.pot.git.get_repo(grading_repo_name)
|
repo: Repo = tea.pot.git.get_repo(grading_repo_name)
|
||||||
now = datetime.now()
|
now = datetime.now()
|
||||||
items = group_config.split(",")
|
items = group_config.split(",")
|
||||||
msg = ""
|
comment = ""
|
||||||
failed = False
|
failed = False
|
||||||
for item in items:
|
for item in items:
|
||||||
name, values = item.split("=")
|
name, values = item.split("=")
|
||||||
|
@ -875,8 +875,8 @@ def joj3_check_env(
|
||||||
submit_count = 0
|
submit_count = 0
|
||||||
commits = repo.iter_commits(paths=scoreboard_file_name, since=since_git_format)
|
commits = repo.iter_commits(paths=scoreboard_file_name, since=since_git_format)
|
||||||
for commit in commits:
|
for commit in commits:
|
||||||
msg = commit.message.strip()
|
comment = commit.message.strip()
|
||||||
lines = msg.splitlines()
|
lines = comment.splitlines()
|
||||||
pattern = (
|
pattern = (
|
||||||
r"joj3: update scoreboard for (?P<exercise_name>.+?) "
|
r"joj3: update scoreboard for (?P<exercise_name>.+?) "
|
||||||
r"by @(?P<submitter>.+) in "
|
r"by @(?P<submitter>.+) in "
|
||||||
|
@ -906,22 +906,27 @@ def joj3_check_env(
|
||||||
)
|
)
|
||||||
use_group = False
|
use_group = False
|
||||||
if name:
|
if name:
|
||||||
msg += f"keyword `{name}` "
|
comment += f"keyword `{name}` "
|
||||||
else:
|
else:
|
||||||
use_group = True
|
use_group = True
|
||||||
for group in groups or "":
|
for group in groups or "":
|
||||||
if group.lower() == name.lower():
|
if group.lower() == name.lower():
|
||||||
use_group = True
|
use_group = True
|
||||||
break
|
break
|
||||||
msg += (
|
comment += (
|
||||||
f"in last {time_period} hour(s): "
|
f"in last {time_period} hour(s): "
|
||||||
f"submit count {submit_count}, "
|
f"submit count {submit_count}, "
|
||||||
f"max count {max_count}"
|
f"max count {max_count}"
|
||||||
)
|
)
|
||||||
if use_group and submit_count + 1 > max_count:
|
if use_group and submit_count + 1 > max_count:
|
||||||
failed = True
|
failed = True
|
||||||
msg += ", exceeded"
|
comment += ", exceeded"
|
||||||
msg += "\n"
|
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
|
print(json.dumps({"msg": msg, "failed": failed})) # print result to stdout for joj3
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user