Skip to content

Commit

Permalink
Merge pull request #13 from xcpcio/feat-more-fields-in-submission
Browse files Browse the repository at this point in the history
feat: add more fields in submission
  • Loading branch information
Dup4 authored Oct 30, 2023
2 parents 81925b0 + 671d935 commit 6c80f54
Show file tree
Hide file tree
Showing 26 changed files with 959 additions and 856 deletions.
1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"execjs",
"gevent",
"grequests",
"guilin",
"gxcpc",
"hbcpc",
"hncpc",
Expand Down
1,723 changes: 880 additions & 843 deletions poetry.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ beautifulsoup4 = "^4.12.2"
lxml = "^4.9.2"
html5lib = "^1.1"
xlrd = "^2.0.1"
domjudge-utility = "^0.0.12"
domjudge-utility = "^0.0.13"
xmltodict = "^0.13.0"

[tool.poetry.dev-dependencies]
Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Empty file.
26 changes: 26 additions & 0 deletions tests/spider/domjudge/v3/domjudge_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import os

from xcpcio_board_spider import Contest, utils
from xcpcio_board_spider.spider.domjudge.v3 import DOMjudge

current_file_path = os.path.abspath(__file__)
current_dir_path = os.path.dirname(current_file_path)


def test_spider_domjudge_v3_9th_ccpc_guilin(snapshot):
test_prefix = "9th_ccpc_guilin"

c = Contest()
c.start_time = utils.get_timestamp_second("2023-10-29 09:00:00")
c.end_time = utils.get_timestamp_second("2023-10-29 14:00:00")

fetch_uri = os.path.join(current_dir_path, "test_data", test_prefix)

d = DOMjudge(c, fetch_uri)
d.fetch().parse_teams().parse_runs()

assert len(d.teams) == 270
assert len(d.runs) == 3360

snapshot.assert_match(d.teams.get_json, "teams")
snapshot.assert_match(d.runs.get_json, "runs")

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[{"id":"group-winner-2","citation":"Winner(s) of group Self-Registered","team_ids":["37"]},{"id":"group-winner-3","citation":"Winner(s) of group Participants","team_ids":["175"]},{"id":"first-to-solve-5","citation":"First to solve problem 5","team_ids":["29"]},{"id":"first-to-solve-6","citation":"First to solve problem 6","team_ids":["8"]},{"id":"first-to-solve-14","citation":"First to solve problem 14","team_ids":["8"]},{"id":"first-to-solve-15","citation":"First to solve problem 15","team_ids":["8"]},{"id":"first-to-solve-10","citation":"First to solve problem 10","team_ids":["46"]},{"id":"first-to-solve-11","citation":"First to solve problem 11","team_ids":["86"]},{"id":"first-to-solve-16","citation":"First to solve problem 16","team_ids":["86"]},{"id":"first-to-solve-4","citation":"First to solve problem 4","team_ids":["175"]},{"id":"first-to-solve-7","citation":"First to solve problem 7","team_ids":["175"]},{"id":"first-to-solve-8","citation":"First to solve problem 8","team_ids":["175"]},{"id":"first-to-solve-12","citation":"First to solve problem 12","team_ids":["175"]},{"id":"first-to-solve-13","citation":"First to solve problem 13","team_ids":["175"]},{"id":"winner","citation":"Contest winner","team_ids":["175"]}]
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"formal_name":"The 9th CCPC Guilin Onsite","penalty_time":20,"start_time":"2023-10-29T09:00:00+08:00","end_time":"2023-10-29T14:00:00+08:00","duration":"5:00:00.000","scoreboard_freeze_duration":"1:00:00.000","id":"5","external_id":null,"name":"The 9th CCPC Guilin Onsite","shortname":"GuilinOnsite"}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[{"hidden":false,"id":"2","icpc_id":null,"name":"Self-Registered","sortorder":0,"color":"#d6a321"},{"hidden":false,"id":"3","icpc_id":null,"name":"Participants","sortorder":0,"color":null},{"hidden":false,"id":"4","icpc_id":null,"name":"Observers","sortorder":1,"color":"#ffcc33"},{"hidden":true,"id":"5","icpc_id":null,"name":"Organisation","sortorder":1,"color":"#ff99cc"},{"hidden":true,"id":"1","icpc_id":null,"name":"System","sortorder":9,"color":"#ff2bea"},{"hidden":true,"id":"6","icpc_id":null,"name":"Jury","sortorder":100,"color":null}]
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[{"id":"CE","name":"compiler error","penalty":false,"solved":false},{"id":"MLE","name":"memory limit","penalty":true,"solved":false},{"id":"OLE","name":"output limit","penalty":true,"solved":false},{"id":"RTE","name":"run error","penalty":true,"solved":false},{"id":"TLE","name":"timelimit","penalty":true,"solved":false},{"id":"WA","name":"wrong answer","penalty":true,"solved":false},{"id":"NO","name":"no output","penalty":true,"solved":false},{"id":"AC","name":"correct","penalty":false,"solved":true}]

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[{"id":"c","name":"C","extensions":["c"],"filter_compiler_files":true,"allow_judge":true,"time_factor":1.0,"entry_point_required":false,"entry_point_name":null},{"id":"cpp","name":"C++","extensions":["cpp","cc","cxx","c++"],"filter_compiler_files":true,"allow_judge":true,"time_factor":1.0,"entry_point_required":false,"entry_point_name":null},{"id":"java","name":"Java","extensions":["java"],"filter_compiler_files":true,"allow_judge":true,"time_factor":1.0,"entry_point_required":false,"entry_point_name":"Main class"},{"id":"python3","name":"Python 3","extensions":["py","py3"],"filter_compiler_files":true,"allow_judge":true,"time_factor":1.0,"entry_point_required":false,"entry_point_name":"Main file"}]

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[{"ordinal":0,"id":"4","short_name":"A","label":"A","time_limit":2.5,"externalid":"diameter-task-11linux","name":"Easy Diameter Problem","rgb":"#9d00ff","color":"darkviolet","test_data_count":52},{"ordinal":1,"id":"5","short_name":"B","label":"B","time_limit":2.0,"externalid":"set-task-14linux","name":"The Game","rgb":"#42ff58","color":"limegreen","test_data_count":74},{"ordinal":2,"id":"6","short_name":"C","label":"C","time_limit":1.0,"externalid":"divide-xor-13linux","name":"Master of Both IV","rgb":"#ffb4f9","color":"lightpink","test_data_count":31},{"ordinal":3,"id":"7","short_name":"D","label":"D","time_limit":2.0,"externalid":"metro-11linux","name":"Subway","rgb":"#29ffd1","color":"turquoise","test_data_count":20},{"ordinal":4,"id":"8","short_name":"E","label":"E","time_limit":2.0,"externalid":"prefix-mahjong-26linux","name":"Prefix Mahjong","rgb":"#ffffff","color":"white","test_data_count":40},{"ordinal":5,"id":"9","short_name":"F","label":"F","time_limit":4.0,"externalid":"cut-vertices-6linux","name":"Redundant Towers","rgb":"#b5b5b5","color":"silver","test_data_count":51},{"ordinal":6,"id":"10","short_name":"G","label":"G","time_limit":1.0,"externalid":"parenthesis-autocomplete-10linux","name":"Hard Brackets Problem","rgb":"#ff0000","color":"red","test_data_count":59},{"ordinal":7,"id":"11","short_name":"H","label":"H","time_limit":2.0,"externalid":"cut-the-tree-1-2-10linux","name":"Sweet Sugar","rgb":"#007542","color":"teal","test_data_count":85},{"ordinal":8,"id":"12","short_name":"I","label":"I","time_limit":2.0,"externalid":"col-mex-interval-16linux","name":"Barkley II","rgb":"#ffff00","color":"yellow","test_data_count":36},{"ordinal":9,"id":"13","short_name":"J","label":"J","time_limit":4.0,"externalid":"two-string-sets-11linux","name":"The Phantom Menace","rgb":"#ff9d00","color":"orange","test_data_count":63},{"ordinal":10,"id":"14","short_name":"K","label":"K","time_limit":2.0,"externalid":"permutation-task-14linux","name":"Randias Permutation Task","rgb":"#adfbff","color":"paleturquoise","test_data_count":48},{"ordinal":11,"id":"15","short_name":"L","label":"L","time_limit":1.0,"externalid":"dice-52linux","name":"Alea Iacta Est","rgb":"#8f6900","color":"olive","test_data_count":148},{"ordinal":12,"id":"16","short_name":"M","label":"M","time_limit":2.5,"externalid":"flip-cards-8linux","name":"Flipping Cards","rgb":"#172eff","color":"blue","test_data_count":16}]

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

17 changes: 14 additions & 3 deletions xcpcio_board_spider/spider/domjudge/v3/domjudge.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import math

from xcpcio_board_spider.type import Contest, Team, Teams, Submission, Submissions, constants

from domjudge_utility import Dump, DumpConfig
Expand Down Expand Up @@ -100,23 +102,32 @@ def parse_runs(self):
submission_id = s["id"]
problem_id = s["problem_id"]
contest_time = s["contest_time"]
language_name = s["language_name"]

time = s["max_run_time"]
if time is not None:
time = int(math.floor(float(time) * 1000))

# ignore submissions that are not submit after contest start
if contest_time.startswith("-"):
continue

timestamp = self.get_submission_timestamp_millisecond(
contest_time) // 1000
timestamp_ms = self.get_submission_timestamp_millisecond(
contest_time)
timestamp = timestamp_ms // 1000

if timestamp > self.contest.end_time - self.contest.start_time:
continue

verdict = s["verdict"]
submission.status = self.parse_result(verdict)

submission.team_id = team_id
submission.submission_id = submission_id
submission.timestamp = timestamp
submission.status = self.parse_result(verdict)
submission.timestamp_ms = timestamp_ms
submission.language = language_name
submission.time = time

p = self.dump.problems_dict[problem_id]
submission.problem_id = p["ordinal"]
Expand Down
21 changes: 18 additions & 3 deletions xcpcio_board_spider/type/submission.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,41 @@

class Submission:
def __init__(self,
status: str = "",
team_id: str = "",
problem_id: int = 0,
timestamp: int = 0,
status: str = "",
timestamp_ms: int = None,
time: int = None,
language: str = None,
submission_id: str = None):
self.status = status
self.team_id = team_id
self.problem_id = problem_id
self.timestamp = timestamp
self.status = status

self.timestamp_ms = timestamp_ms
self.time = time
self.language = language
self.submission_id = submission_id

@property
def get_dict(self):
obj = {}

obj["status"] = self.status
obj["team_id"] = self.team_id
obj["problem_id"] = self.problem_id
obj["timestamp"] = self.timestamp
obj["status"] = self.status

if self.timestamp_ms is not None:
obj["timestamp_ms"] = self.timestamp_ms

if self.time is not None:
obj["time"] = self.time

if self.language is not None:
obj["language"] = self.language

if self.submission_id is not None:
obj["submission_id"] = self.submission_id
Expand Down

0 comments on commit 6c80f54

Please sign in to comment.