From ac8aea5c466094e08cba1e6d4e2b1a7217eadd36 Mon Sep 17 00:00:00 2001 From: XYCode Kerman Date: Mon, 8 Apr 2024 22:39:10 +0800 Subject: [PATCH 1/6] =?UTF-8?q?chore(manager):=20ItsWA=E4=B8=8B=E8=BD=BDUR?= =?UTF-8?q?L?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 将ItsWA Editor版本从从beta-v0.1迁移到beta-v0.1.1 --- manager/cli/base.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manager/cli/base.py b/manager/cli/base.py index 987a410..7fdbaf3 100644 --- a/manager/cli/base.py +++ b/manager/cli/base.py @@ -33,7 +33,7 @@ def download_ited(): ited_zipfile_path.touch() res = requests.get( - 'https://mirror.ghproxy.com/https://github.com/XYCode-Kerman/ItsWA-Editor/releases/download/beta-v0.1/dist.zip', stream=True) + 'https://mirror.ghproxy.com/https://github.com/XYCode-Kerman/ItsWA-Editor/releases/download/beta-v0.1.1/dist.zip', stream=True) fs = ited_zipfile_path.open('wb') for data in track(res.iter_content(chunk_size=128), '下载 ItsWA Editor 中', total=round(int(res.headers['Content-Length']) / 128)): From 31ac7f93a6b82b3713374eb6e3e4868dcce6f3ce Mon Sep 17 00:00:00 2001 From: XYCode Kerman Date: Mon, 8 Apr 2024 22:43:48 +0800 Subject: [PATCH 2/6] =?UTF-8?q?docs:=20=E6=8F=90=E4=BA=A4=E4=BF=A1?= =?UTF-8?q?=E6=81=AF=E9=87=87=E7=94=A8=E2=80=9C=E7=BA=A6=E5=AE=9A=E5=BC=8F?= =?UTF-8?q?=E6=8F=90=E4=BA=A4=E2=80=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index d6ad9d4..60dcec4 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # ItsWA -![GitHub License](https://img.shields.io/github/license/XYCode-Kerman/ItsWA?style=flat-square) +![GitHub License](https://img.shields.io/github/license/XYCode-Kerman/ItsWA?style=flat-square) [![Conventional Commits](https://img.shields.io/badge/Conventional%20Commits-1.0.0-%23FE5196?logo=conventionalcommits&logoColor=white)](https://conventionalcommits.org) ![GitHub last commit (branch)](https://img.shields.io/github/last-commit/XYCode-Kerman/ItsWA/master?style=flat-square&label=Last%20Commit%20on%20Master) ![Codecov (with branch)](https://img.shields.io/codecov/c/github/XYCode-Kerman/ItsWA/master?style=flat-square&label=Coverage%20on%20Master) @@ -29,6 +29,10 @@ xycode-xyc@outlook.com,获得许可后您可无视 GNU 通用公共许可证 ## 关于开发 +### 提交规范 + +本项目自2024年4月8日起采用[**约定式提交 v1.0.0**](https://www.conventionalcommits.org/zh-hans/v1.0.0/)作为提交的格式规范,语言为**中文**,不符合提交规范的代码将会被拒绝! + ### 测试结果(来自CodeCov) ![codecov.io/gh/XYCode-Kerman/ItsWA/graphs/icicle.svg?token=8knjccNoca](https://codecov.io/gh/XYCode-Kerman/ItsWA/graphs/icicle.svg?token=8knjccNoca) From f59293d4698588409cfec08628857460f613e203 Mon Sep 17 00:00:00 2001 From: XYCode Kerman Date: Mon, 8 Apr 2024 23:30:24 +0800 Subject: [PATCH 3/6] =?UTF-8?q?feat(judge)!:=20=E8=AF=84=E6=B5=8B=E9=87=87?= =?UTF-8?q?=E7=94=A8=E7=94=9F=E6=88=90=E5=99=A8=E5=BD=A2=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 评测采用了生成器形式,使得WebUI可以即时展示评测出的结果,而无需长时间等待 --- judge/base.py | 6 ++++-- manager/api/routers/contest/judge.py | 13 ++++++++++++- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/judge/base.py b/judge/base.py index f46cff7..55e8033 100644 --- a/judge/base.py +++ b/judge/base.py @@ -1,6 +1,7 @@ import datetime import json from pathlib import Path +from typing import * from typing import List from ccf_parser import CCF @@ -10,7 +11,7 @@ from .player import Player -def start_judging(ccf: CCF): +def start_judging(ccf: CCF) -> Generator[List[JudgingResult], Any, Any]: start = datetime.datetime.now() judging_results: List[JudgingResult] = [] judge_logger.info(f'开始评测比赛 {ccf.header.name},当前时间:{start}') @@ -31,6 +32,8 @@ def start_judging(ccf: CCF): for player in players: result = player.judging(ccf) judging_results.append(result) + yield result + judge_logger.info(f'选手 {player.order} 评测完成。') # 保存评测数据 Path(ccf.header.path).joinpath('./judging_results.json').write_text( @@ -45,4 +48,3 @@ def start_judging(ccf: CCF): end = datetime.datetime.now() judge_logger.info( f'评测比赛 {ccf.header.name} 完成,当前时间:{end},总用时:{end - start}') - return judging_results diff --git a/manager/api/routers/contest/judge.py b/manager/api/routers/contest/judge.py index 9ac9324..ef49d7f 100644 --- a/manager/api/routers/contest/judge.py +++ b/manager/api/routers/contest/judge.py @@ -11,10 +11,16 @@ router = APIRouter(prefix='/judge', tags=['评测管理']) trackIds2Results: Dict[uuid.UUID, List[ccf_parser.JudgingResult]] = {} +judging: List[uuid.UUID] = [] def start_judging_task(ccf: ccf_parser.CCF, trackId: uuid.UUID): - trackIds2Results[trackId] = judge.start_judging(ccf) + # trackIds2Results[trackId] = judge.start_judging(ccf) + trackIds2Results[trackId] = [] + judging.append(trackId) + for result in judge.start_judging(ccf): + trackIds2Results[trackId].append(result) + judging.remove(trackId) @router.post('/start', name='开始评测', response_model=Dict[str, str], responses={ @@ -60,3 +66,8 @@ async def get_judging_result(trackId: uuid.UUID): raise fastapi.HTTPException(status_code=404, detail='trackId 不存在') return trackIds2Results[trackId] + + +@router.get('/is_judging/{trackId}', name='获取某个比赛是否处于评测状态', response_model=bool) +async def get_contest_is_judging(trackId: uuid.UUID): + return trackId in judging From fcf0def3f8fcbce9e3aaf1d58ae9e2561772b544 Mon Sep 17 00:00:00 2001 From: XYCode Kerman Date: Mon, 8 Apr 2024 23:34:37 +0800 Subject: [PATCH 4/6] =?UTF-8?q?fix(manager):=20=E5=85=BC=E5=AE=B9=E7=94=9F?= =?UTF-8?q?=E6=88=90=E5=99=A8=E5=BD=A2=E5=BC=8F=E7=9A=84=E8=AF=84=E6=B5=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- manager/cli/judge.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/manager/cli/judge.py b/manager/cli/judge.py index 690b0e5..7ac2a1a 100644 --- a/manager/cli/judge.py +++ b/manager/cli/judge.py @@ -22,7 +22,8 @@ def start_judging_command(path: Annotated[Path, typer.Argument(help='比赛目 else: raise FileNotFoundError('评测目录不正确,可能是不存在CCF文件') - start_judging(ccf) + list(start_judging(ccf)) + return 0 From 88a32e2c186adf9118771411d07930caae7a5712 Mon Sep 17 00:00:00 2001 From: XYCode Kerman Date: Mon, 8 Apr 2024 23:36:19 +0800 Subject: [PATCH 5/6] =?UTF-8?q?test(manager):=20=E7=94=9F=E6=88=90?= =?UTF-8?q?=E5=99=A8=E5=BD=A2=E5=BC=8F=E8=AF=84=E6=B5=8B=E7=9A=84CLI?= =?UTF-8?q?=E5=B7=A5=E5=85=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/test_judge.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_judge.py b/tests/test_judge.py index 5f96229..586ef28 100644 --- a/tests/test_judge.py +++ b/tests/test_judge.py @@ -56,7 +56,7 @@ def test_compile(temp_contest: Path): def test_start_juding(temp_contest: Path): ccf = CCF(**json.loads(temp_contest.joinpath('ccf.json').read_text('utf-8'))) - results = start_judging(ccf) + results = list(start_judging(ccf)) # 分析 analyzed = ReportAnalyze(results).generate() From 152898daa47c4b1ba53c02b2d8a466cd6bd8eb04 Mon Sep 17 00:00:00 2001 From: XYCode Kerman Date: Mon, 8 Apr 2024 23:39:46 +0800 Subject: [PATCH 6/6] =?UTF-8?q?chore(manager):=20=E4=BF=AE=E6=94=B9ITED?= =?UTF-8?q?=E4=B8=8B=E8=BD=BD=E5=9C=B0=E5=9D=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- manager/cli/base.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manager/cli/base.py b/manager/cli/base.py index 7fdbaf3..c8660d5 100644 --- a/manager/cli/base.py +++ b/manager/cli/base.py @@ -33,7 +33,7 @@ def download_ited(): ited_zipfile_path.touch() res = requests.get( - 'https://mirror.ghproxy.com/https://github.com/XYCode-Kerman/ItsWA-Editor/releases/download/beta-v0.1.1/dist.zip', stream=True) + 'https://mirror.ghproxy.com/https://github.com/XYCode-Kerman/ItsWA-Editor/releases/download/beta-v0.1.2/dist.zip', stream=True) fs = ited_zipfile_path.open('wb') for data in track(res.iter_content(chunk_size=128), '下载 ItsWA Editor 中', total=round(int(res.headers['Content-Length']) / 128)):