Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
XYCode-Kerman committed Apr 8, 2024
2 parents ff3bf54 + 152898d commit cb2d173
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 7 deletions.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -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)

Expand Down Expand Up @@ -29,6 +29,10 @@ [email protected],获得许可后您可无视 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)
Expand Down
6 changes: 4 additions & 2 deletions judge/base.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import datetime
import json
from pathlib import Path
from typing import *
from typing import List

from ccf_parser import CCF
Expand All @@ -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}')
Expand All @@ -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(
Expand All @@ -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
13 changes: 12 additions & 1 deletion manager/api/routers/contest/judge.py
Original file line number Diff line number Diff line change
Expand Up @@ -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={
Expand Down Expand Up @@ -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
2 changes: 1 addition & 1 deletion manager/cli/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.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)):
Expand Down
3 changes: 2 additions & 1 deletion manager/cli/judge.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down
2 changes: 1 addition & 1 deletion tests/test_judge.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit cb2d173

Please sign in to comment.