feat: max total score
This commit is contained in:
parent
cf9ba49d18
commit
2bc0a0a18d
|
@ -468,6 +468,10 @@ def joj3_all(
|
||||||
"unknown",
|
"unknown",
|
||||||
help="JOJ3 run ID",
|
help="JOJ3 run ID",
|
||||||
),
|
),
|
||||||
|
max_total_score: int = Argument(
|
||||||
|
-1,
|
||||||
|
help="max total score",
|
||||||
|
),
|
||||||
skip_result_issue: bool = Option(
|
skip_result_issue: bool = Option(
|
||||||
False,
|
False,
|
||||||
help="skip creating result issue on gitea",
|
help="skip creating result issue on gitea",
|
||||||
|
@ -508,8 +512,11 @@ def joj3_all(
|
||||||
commit_hash,
|
commit_hash,
|
||||||
submitter_in_issue_title,
|
submitter_in_issue_title,
|
||||||
run_id,
|
run_id,
|
||||||
|
max_total_score,
|
||||||
|
)
|
||||||
|
title_prefix = joj3.get_title_prefix(
|
||||||
|
exercise_name, submitter, submitter_in_issue_title
|
||||||
)
|
)
|
||||||
title_prefix = joj3.get_title_prefix(title)
|
|
||||||
joj3_issue: focs_gitea.Issue
|
joj3_issue: focs_gitea.Issue
|
||||||
issue: focs_gitea.Issue
|
issue: focs_gitea.Issue
|
||||||
for issue in tea.pot.gitea.issue_api.issue_list_issues(
|
for issue in tea.pot.gitea.issue_api.issue_list_issues(
|
||||||
|
|
|
@ -188,6 +188,7 @@ def generate_title_and_comment(
|
||||||
commit_hash: str,
|
commit_hash: str,
|
||||||
submitter_in_title: bool = True,
|
submitter_in_title: bool = True,
|
||||||
run_id: str = "unknown",
|
run_id: str = "unknown",
|
||||||
|
max_total_score: int = -1,
|
||||||
) -> Tuple[str, str]:
|
) -> Tuple[str, str]:
|
||||||
with open(score_file_path) as json_file:
|
with open(score_file_path) as json_file:
|
||||||
stages: List[Dict[str, Any]] = json.load(json_file)
|
stages: List[Dict[str, Any]] = json.load(json_file)
|
||||||
|
@ -227,9 +228,12 @@ def generate_title_and_comment(
|
||||||
comment += "</details>\n\n"
|
comment += "</details>\n\n"
|
||||||
total_score += result["score"]
|
total_score += result["score"]
|
||||||
comment += "\n"
|
comment += "\n"
|
||||||
title = f"JOJ3 Result for {exercise_name} by @{submitter} - Score: {total_score}"
|
title = get_title_prefix(exercise_name, submitter, submitter_in_title)
|
||||||
if not submitter_in_title:
|
if max_total_score >= 0:
|
||||||
title = f"JOJ3 Result for {exercise_name} - Score: {total_score}"
|
total_score = min(total_score, max_total_score)
|
||||||
|
title += f"{total_score} / {max_total_score}"
|
||||||
|
else:
|
||||||
|
title += f"{total_score}"
|
||||||
return title, comment
|
return title, comment
|
||||||
|
|
||||||
|
|
||||||
|
@ -245,12 +249,10 @@ def check_skipped(score_file_path: str, keyword: str) -> bool:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
def get_title_prefix(title: str) -> str:
|
def get_title_prefix(
|
||||||
meet_negative = False
|
exercise_name: str, submitter: str, submitter_in_title: bool
|
||||||
for i in range(len(title) - 1, -1, -1):
|
) -> str:
|
||||||
if not title[i].isdigit() and not title[i].isspace():
|
title = f"JOJ3 Result for {exercise_name} by @{submitter} - "
|
||||||
if not meet_negative and title[i] == "-":
|
if not submitter_in_title:
|
||||||
meet_negative = True
|
title = f"JOJ3 Result for {exercise_name} - "
|
||||||
continue
|
return title
|
||||||
return title[: i + 1]
|
|
||||||
return ""
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user