@xcpcio/core 0.6.2 → 0.6.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -188,7 +188,6 @@ class Group {
188
188
  class Contest {
189
189
  constructor() {
190
190
  this.name = "";
191
- this.version = types.VERSION;
192
191
  this.startTime = createDayJS();
193
192
  this.endTime = createDayJS();
194
193
  this.freezeTime = createDayJS();
@@ -769,6 +768,24 @@ class RankOptions {
769
768
  this.filterTeams = filterTeams;
770
769
  this.filterTeamMap = m;
771
770
  }
771
+ isNeedReBuildRank(nextRankOptions) {
772
+ if (this.enableFilterSubmissionsByTimestamp !== nextRankOptions.enableFilterSubmissionsByTimestamp) {
773
+ return true;
774
+ }
775
+ if (this.width !== nextRankOptions.width) {
776
+ return true;
777
+ }
778
+ if (this.timestamp !== nextRankOptions.timestamp) {
779
+ return true;
780
+ }
781
+ if (this.enableFilterTeamsByGroup !== nextRankOptions.enableFilterTeamsByGroup) {
782
+ return true;
783
+ }
784
+ if (this.group !== nextRankOptions.group) {
785
+ return true;
786
+ }
787
+ return false;
788
+ }
772
789
  }
773
790
  class Rank {
774
791
  constructor(contest, teams, submissions) {
@@ -807,8 +824,6 @@ class Rank {
807
824
  this.contest.problems.forEach((p) => {
808
825
  p.statistics.reset();
809
826
  });
810
- let preSubmissionTimestampToMinute = 0;
811
- const allSubmissions = this.getSubmissions();
812
827
  this.teams.forEach(
813
828
  (t) => t.placeChartPoints.push({
814
829
  timePoint: 0,
@@ -816,6 +831,12 @@ class Rank {
816
831
  lastSolvedProblem: null
817
832
  })
818
833
  );
834
+ (() => {
835
+ this.rankStatistics.reset();
836
+ this.rankStatistics.teamSolvedNum = Array(this.contest.problems.length + 1).fill(0);
837
+ })();
838
+ let preSubmissionTimestampToMinute = 0;
839
+ const allSubmissions = this.getSubmissions();
819
840
  for (let ix = 0; ix < allSubmissions.length; ix++) {
820
841
  const s = allSubmissions[ix];
821
842
  const teamId = s.teamId;
@@ -890,8 +911,6 @@ class Rank {
890
911
  this.teams.forEach((t) => t.postProcessPlaceChartPoints());
891
912
  })();
892
913
  (() => {
893
- this.rankStatistics.reset();
894
- this.rankStatistics.teamSolvedNum = Array(this.contest.problems.length + 1).fill(0);
895
914
  for (const t of this.teams) {
896
915
  this.rankStatistics.teamSolvedNum[t.solvedProblemNum]++;
897
916
  }
package/dist/index.d.ts CHANGED
@@ -104,7 +104,6 @@ declare class Contest {
104
104
  logo?: Image;
105
105
  banner?: Image;
106
106
  boardLink?: string;
107
- version: string;
108
107
  constructor();
109
108
  getContestDuration(timeFormat?: string): string;
110
109
  getContestState(nowTime?: Date): ContestState;
@@ -205,6 +204,7 @@ declare class RankOptions {
205
204
  disableFilterTeamsByGroup(): void;
206
205
  setFilterOrganizations(filterOrganizations: Array<SelectOptionItem>): void;
207
206
  setFilterTeams(filterTeams: Array<SelectOptionItem>): void;
207
+ isNeedReBuildRank(nextRankOptions: RankOptions): boolean;
208
208
  }
209
209
  declare class Rank {
210
210
  readonly contest: Contest;
package/dist/index.mjs CHANGED
@@ -8,7 +8,7 @@ import isSameOrBefore from 'dayjs/plugin/isSameOrBefore';
8
8
  import isSameOrAfter from 'dayjs/plugin/isSameOrAfter';
9
9
  import minMax from 'dayjs/plugin/minMax';
10
10
  import relativeTime from 'dayjs/plugin/relativeTime';
11
- import { VERSION, ContestState, SubmissionStatus } from '@xcpcio/types';
11
+ import { ContestState, SubmissionStatus } from '@xcpcio/types';
12
12
  import _ from 'lodash';
13
13
 
14
14
  function calcDict(attemptedNum, solvedNum) {
@@ -172,7 +172,6 @@ class Group {
172
172
  class Contest {
173
173
  constructor() {
174
174
  this.name = "";
175
- this.version = VERSION;
176
175
  this.startTime = createDayJS();
177
176
  this.endTime = createDayJS();
178
177
  this.freezeTime = createDayJS();
@@ -753,6 +752,24 @@ class RankOptions {
753
752
  this.filterTeams = filterTeams;
754
753
  this.filterTeamMap = m;
755
754
  }
755
+ isNeedReBuildRank(nextRankOptions) {
756
+ if (this.enableFilterSubmissionsByTimestamp !== nextRankOptions.enableFilterSubmissionsByTimestamp) {
757
+ return true;
758
+ }
759
+ if (this.width !== nextRankOptions.width) {
760
+ return true;
761
+ }
762
+ if (this.timestamp !== nextRankOptions.timestamp) {
763
+ return true;
764
+ }
765
+ if (this.enableFilterTeamsByGroup !== nextRankOptions.enableFilterTeamsByGroup) {
766
+ return true;
767
+ }
768
+ if (this.group !== nextRankOptions.group) {
769
+ return true;
770
+ }
771
+ return false;
772
+ }
756
773
  }
757
774
  class Rank {
758
775
  constructor(contest, teams, submissions) {
@@ -791,8 +808,6 @@ class Rank {
791
808
  this.contest.problems.forEach((p) => {
792
809
  p.statistics.reset();
793
810
  });
794
- let preSubmissionTimestampToMinute = 0;
795
- const allSubmissions = this.getSubmissions();
796
811
  this.teams.forEach(
797
812
  (t) => t.placeChartPoints.push({
798
813
  timePoint: 0,
@@ -800,6 +815,12 @@ class Rank {
800
815
  lastSolvedProblem: null
801
816
  })
802
817
  );
818
+ (() => {
819
+ this.rankStatistics.reset();
820
+ this.rankStatistics.teamSolvedNum = Array(this.contest.problems.length + 1).fill(0);
821
+ })();
822
+ let preSubmissionTimestampToMinute = 0;
823
+ const allSubmissions = this.getSubmissions();
803
824
  for (let ix = 0; ix < allSubmissions.length; ix++) {
804
825
  const s = allSubmissions[ix];
805
826
  const teamId = s.teamId;
@@ -874,8 +895,6 @@ class Rank {
874
895
  this.teams.forEach((t) => t.postProcessPlaceChartPoints());
875
896
  })();
876
897
  (() => {
877
- this.rankStatistics.reset();
878
- this.rankStatistics.teamSolvedNum = Array(this.contest.problems.length + 1).fill(0);
879
898
  for (const t of this.teams) {
880
899
  this.rankStatistics.teamSolvedNum[t.solvedProblemNum]++;
881
900
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xcpcio/core",
3
- "version": "0.6.2",
3
+ "version": "0.6.4",
4
4
  "description": "XCPCIO Core",
5
5
  "author": "Dup4 <lyuzhi.pan@gmail.com>",
6
6
  "license": "MIT",
@@ -42,7 +42,7 @@
42
42
  "dependencies": {
43
43
  "dayjs": "^1.11.8",
44
44
  "lodash": "^4.17.21",
45
- "@xcpcio/types": "0.6.2"
45
+ "@xcpcio/types": "0.6.4"
46
46
  },
47
47
  "devDependencies": {
48
48
  "@babel/types": "^7.22.4",
package/src/contest.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import type { Contest as IContest, Image, StatusTimeDisplay } from "@xcpcio/types";
2
- import { ContestState, VERSION } from "@xcpcio/types";
2
+ import { ContestState } from "@xcpcio/types";
3
3
 
4
4
  import type { Problem, Problems } from "./problem";
5
5
  import { createProblems, createProblemsByProblemIds } from "./problem";
@@ -35,8 +35,6 @@ export class Contest {
35
35
  banner?: Image;
36
36
  boardLink?: string;
37
37
 
38
- version = VERSION;
39
-
40
38
  constructor() {
41
39
  this.startTime = createDayJS();
42
40
  this.endTime = createDayJS();
package/src/rank.ts CHANGED
@@ -83,6 +83,30 @@ export class RankOptions {
83
83
  this.filterTeams = filterTeams;
84
84
  this.filterTeamMap = m;
85
85
  }
86
+
87
+ isNeedReBuildRank(nextRankOptions: RankOptions): boolean {
88
+ if (this.enableFilterSubmissionsByTimestamp !== nextRankOptions.enableFilterSubmissionsByTimestamp) {
89
+ return true;
90
+ }
91
+
92
+ if (this.width !== nextRankOptions.width) {
93
+ return true;
94
+ }
95
+
96
+ if (this.timestamp !== nextRankOptions.timestamp) {
97
+ return true;
98
+ }
99
+
100
+ if (this.enableFilterTeamsByGroup !== nextRankOptions.enableFilterTeamsByGroup) {
101
+ return true;
102
+ }
103
+
104
+ if (this.group !== nextRankOptions.group) {
105
+ return true;
106
+ }
107
+
108
+ return false;
109
+ }
86
110
  }
87
111
 
88
112
  export class Rank {
@@ -151,9 +175,6 @@ export class Rank {
151
175
  p.statistics.reset();
152
176
  });
153
177
 
154
- let preSubmissionTimestampToMinute = 0;
155
- const allSubmissions = this.getSubmissions();
156
-
157
178
  this.teams.forEach(t =>
158
179
  t.placeChartPoints.push({
159
180
  timePoint: 0,
@@ -162,6 +183,14 @@ export class Rank {
162
183
  }),
163
184
  );
164
185
 
186
+ (() => {
187
+ this.rankStatistics.reset();
188
+ this.rankStatistics.teamSolvedNum = Array(this.contest.problems.length + 1).fill(0);
189
+ })();
190
+
191
+ let preSubmissionTimestampToMinute = 0;
192
+ const allSubmissions = this.getSubmissions();
193
+
165
194
  for (let ix = 0; ix < allSubmissions.length; ix++) {
166
195
  const s = allSubmissions[ix];
167
196
 
@@ -260,9 +289,6 @@ export class Rank {
260
289
  })();
261
290
 
262
291
  (() => {
263
- this.rankStatistics.reset();
264
-
265
- this.rankStatistics.teamSolvedNum = Array(this.contest.problems.length + 1).fill(0);
266
292
  for (const t of this.teams) {
267
293
  this.rankStatistics.teamSolvedNum[t.solvedProblemNum]++;
268
294
  }