From 21db58dead1c1fb568f0f1b229ae21b9c9085761 Mon Sep 17 00:00:00 2001 From: Dup4 Date: Sun, 13 Oct 2024 11:21:31 +0800 Subject: [PATCH] Support update problem_quantity for csg cpc Signed-off-by: Dup4 --- .../test_spider_csg_cpc_v1_2023_hncpc/contest | 2 +- .../spider/csg_cpc/v1/csg_cpc.py | 18 ++++++++++++++---- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/tests/spider/csg_cpc/v1/snapshots/csg_cpc_test/test_spider_csg_cpc_v1_2023_hncpc/contest b/tests/spider/csg_cpc/v1/snapshots/csg_cpc_test/test_spider_csg_cpc_v1_2023_hncpc/contest index fd591d1..871f324 100644 --- a/tests/spider/csg_cpc/v1/snapshots/csg_cpc_test/test_spider_csg_cpc_v1_2023_hncpc/contest +++ b/tests/spider/csg_cpc/v1/snapshots/csg_cpc_test/test_spider_csg_cpc_v1_2023_hncpc/contest @@ -1 +1 @@ -{"contest_name": "", "start_time": 1694912400, "end_time": 1694930400, "frozen_time": 3600, "penalty": 1200, "problem_quantity": 0, "problem_id": [], "group": {"official": "\u6b63\u5f0f\u961f\u4f0d", "unofficial": "\u6253\u661f\u961f\u4f0d"}, "organization": "School", "status_time_display": {"correct": true, "incorrect": true, "pending": true}, "medal": {}, "options": {}} \ No newline at end of file +{"contest_name": "", "start_time": 1694912400, "end_time": 1694930400, "frozen_time": 3600, "penalty": 1200, "problem_quantity": 11, "problem_id": ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K"], "group": {"official": "\u6b63\u5f0f\u961f\u4f0d", "unofficial": "\u6253\u661f\u961f\u4f0d"}, "organization": "School", "status_time_display": {"correct": true, "incorrect": true, "pending": true}, "medal": {}, "balloon_color": [{"color": "#fff", "background_color": "rgba(189, 14, 14, 0.7)"}, {"color": "#fff", "background_color": "rgba(149, 31, 217, 0.7)"}, {"color": "#fff", "background_color": "rgba(16, 32, 96, 0.7)"}, {"color": "#000", "background_color": "rgba(38, 185, 60, 0.7)"}, {"color": "#000", "background_color": "rgba(239, 217, 9, 0.7)"}, {"color": "#fff", "background_color": "rgba(243, 88, 20, 0.7)"}, {"color": "#fff", "background_color": "rgba(12, 76, 138, 0.7)"}, {"color": "#000", "background_color": "rgba(156, 155, 155, 0.7)"}, {"color": "#000", "background_color": "rgba(4, 154, 115, 0.7)"}, {"color": "#fff", "background_color": "rgba(159, 19, 236, 0.7)"}, {"color": "#000", "background_color": "rgba(42, 197, 202, 0.7)"}], "options": {}} \ No newline at end of file diff --git a/xcpcio_board_spider/spider/csg_cpc/v1/csg_cpc.py b/xcpcio_board_spider/spider/csg_cpc/v1/csg_cpc.py index fc0f4fc..2d08425 100644 --- a/xcpcio_board_spider/spider/csg_cpc/v1/csg_cpc.py +++ b/xcpcio_board_spider/spider/csg_cpc/v1/csg_cpc.py @@ -1,9 +1,18 @@ -import typing -import requests import json import os +import typing -from xcpcio_board_spider import Contest, Team, Teams, Submission, Submissions, utils, constants +import requests + +from xcpcio_board_spider import ( + Contest, + Submission, + Submissions, + Team, + Teams, + constants, + utils, +) class CSG_CPC(): @@ -211,7 +220,8 @@ def update_contest(self): self.contest.start_time = self.get_timestamp_from_date(start_time) self.contest.end_time = self.get_timestamp_from_date(end_time) - self.contest.frozen_time = int(frozen_minute) * 60 + self.contest.problem_quantity = len(self.raw_problem_data) + self.contest.fill_problem_id().fill_balloon_color() return self