@algoux/standard-ranklist-utils 0.2.8 → 0.2.10
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/README.md +1 -0
- package/dist/index.cjs +30 -2
- package/dist/index.d.cts +2 -1
- package/dist/index.d.mts +2 -1
- package/dist/index.mjs +30 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -35,6 +35,7 @@ npm i -S @algoux/standard-ranklist-utils
|
|
|
35
35
|
- `getSortedCalculatedRawSolutions`
|
|
36
36
|
- `filterSolutionsUntil`
|
|
37
37
|
- `sortRows`
|
|
38
|
+
- `calculateProblemStatistics`
|
|
38
39
|
- `regenerateRanklistBySolutions`
|
|
39
40
|
- `regenerateRowsByIncrementalSolutions`
|
|
40
41
|
- `convertToStaticRanklist`
|
package/dist/index.cjs
CHANGED
|
@@ -291,6 +291,27 @@ function cloneDeep(obj) {
|
|
|
291
291
|
}
|
|
292
292
|
return clonedObj;
|
|
293
293
|
}
|
|
294
|
+
function calculateProblemStatistics(ranklist) {
|
|
295
|
+
const problemCount = ranklist.problems.length;
|
|
296
|
+
const problemAcceptedCount = new Array(problemCount).fill(0);
|
|
297
|
+
const problemSubmittedCount = new Array(problemCount).fill(0);
|
|
298
|
+
for (const row of ranklist.rows) {
|
|
299
|
+
for (let i = 0; i < problemCount; i++) {
|
|
300
|
+
const status = row.statuses[i];
|
|
301
|
+
if (!(status == null ? void 0 : status.result)) {
|
|
302
|
+
continue;
|
|
303
|
+
}
|
|
304
|
+
if (status.result === "AC" || status.result === "FB") {
|
|
305
|
+
problemAcceptedCount[i] += 1;
|
|
306
|
+
}
|
|
307
|
+
problemSubmittedCount[i] += status.tries || 0;
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
return ranklist.problems.map((_, index) => ({
|
|
311
|
+
accepted: problemAcceptedCount[index],
|
|
312
|
+
submitted: problemSubmittedCount[index]
|
|
313
|
+
}));
|
|
314
|
+
}
|
|
294
315
|
function regenerateRanklistBySolutions(originalRanklist, solutions) {
|
|
295
316
|
var _a;
|
|
296
317
|
if (!canRegenerateRanklist(originalRanklist)) {
|
|
@@ -298,7 +319,7 @@ function regenerateRanklistBySolutions(originalRanklist, solutions) {
|
|
|
298
319
|
}
|
|
299
320
|
const sorterConfig = {
|
|
300
321
|
penalty: [20, "min"],
|
|
301
|
-
noPenaltyResults: ["FB", "AC", "?", "CE", "UKE", null],
|
|
322
|
+
noPenaltyResults: ["FB", "AC", "?", "NOUT", "CE", "UKE", null],
|
|
302
323
|
timeRounding: "floor",
|
|
303
324
|
...cloneDeep(((_a = originalRanklist.sorter) == null ? void 0 : _a.config) || {})
|
|
304
325
|
};
|
|
@@ -405,7 +426,7 @@ function regenerateRowsByIncrementalSolutions(originalRanklist, solutions) {
|
|
|
405
426
|
}
|
|
406
427
|
const sorterConfig = {
|
|
407
428
|
penalty: [20, "min"],
|
|
408
|
-
noPenaltyResults: ["FB", "AC", "?", "CE", "UKE", null],
|
|
429
|
+
noPenaltyResults: ["FB", "AC", "?", "NOUT", "CE", "UKE", null],
|
|
409
430
|
timeRounding: "floor",
|
|
410
431
|
...cloneDeep(((_a = originalRanklist.sorter) == null ? void 0 : _a.config) || {})
|
|
411
432
|
};
|
|
@@ -554,6 +575,12 @@ function genSeriesCalcFns(series, rows, ranks, officialRanks) {
|
|
|
554
575
|
if (value === void 0) {
|
|
555
576
|
return false;
|
|
556
577
|
}
|
|
578
|
+
if (typeof value === "object") {
|
|
579
|
+
return Object.values(value).some((v) => new RegExp(rule2).test(`${v}`));
|
|
580
|
+
}
|
|
581
|
+
if (Array.isArray(value)) {
|
|
582
|
+
return value.some((v) => new RegExp(rule2).test(`${v}`));
|
|
583
|
+
}
|
|
557
584
|
return new RegExp(rule2).test(`${value}`);
|
|
558
585
|
});
|
|
559
586
|
});
|
|
@@ -722,6 +749,7 @@ function convertToStaticRanklist(ranklist) {
|
|
|
722
749
|
exports.EnumTheme = EnumTheme;
|
|
723
750
|
exports.MIN_REGEN_SUPPORTED_VERSION = MIN_REGEN_SUPPORTED_VERSION;
|
|
724
751
|
exports.alphabetToNumber = alphabetToNumber;
|
|
752
|
+
exports.calculateProblemStatistics = calculateProblemStatistics;
|
|
725
753
|
exports.canRegenerateRanklist = canRegenerateRanklist;
|
|
726
754
|
exports.convertToStaticRanklist = convertToStaticRanklist;
|
|
727
755
|
exports.filterSolutionsUntil = filterSolutionsUntil;
|
package/dist/index.d.cts
CHANGED
|
@@ -96,8 +96,9 @@ declare function canRegenerateRanklist(ranklist: srk.Ranklist): boolean;
|
|
|
96
96
|
declare function getSortedCalculatedRawSolutions(rows: srk.RanklistRow[]): CalculatedSolutionTetrad[];
|
|
97
97
|
declare function filterSolutionsUntil(solutions: CalculatedSolutionTetrad[], time: srk.TimeDuration): CalculatedSolutionTetrad[];
|
|
98
98
|
declare function sortRows(rows: srk.RanklistRow[]): srk.RanklistRow[];
|
|
99
|
+
declare function calculateProblemStatistics(ranklist: srk.Ranklist): srk.ProblemStatistics[];
|
|
99
100
|
declare function regenerateRanklistBySolutions(originalRanklist: srk.Ranklist, solutions: CalculatedSolutionTetrad[]): srk.Ranklist;
|
|
100
101
|
declare function regenerateRowsByIncrementalSolutions(originalRanklist: srk.Ranklist, solutions: CalculatedSolutionTetrad[]): srk.RanklistRow[];
|
|
101
102
|
declare function convertToStaticRanklist(ranklist: srk.Ranklist): StaticRanklist;
|
|
102
103
|
|
|
103
|
-
export { type CalculatedSolutionTetrad, EnumTheme, MIN_REGEN_SUPPORTED_VERSION, type RankValue, type StaticRanklist, type ThemeColor, alphabetToNumber, canRegenerateRanklist, convertToStaticRanklist, filterSolutionsUntil, formatTimeDuration, getSortedCalculatedRawSolutions, numberToAlphabet, preZeroFill, regenerateRanklistBySolutions, regenerateRowsByIncrementalSolutions, resolveColor, resolveContributor, resolveStyle, resolveText, resolveThemeColor, resolveUserMarkers, secToTimeStr, sortRows };
|
|
104
|
+
export { type CalculatedSolutionTetrad, EnumTheme, MIN_REGEN_SUPPORTED_VERSION, type RankValue, type StaticRanklist, type ThemeColor, alphabetToNumber, calculateProblemStatistics, canRegenerateRanklist, convertToStaticRanklist, filterSolutionsUntil, formatTimeDuration, getSortedCalculatedRawSolutions, numberToAlphabet, preZeroFill, regenerateRanklistBySolutions, regenerateRowsByIncrementalSolutions, resolveColor, resolveContributor, resolveStyle, resolveText, resolveThemeColor, resolveUserMarkers, secToTimeStr, sortRows };
|
package/dist/index.d.mts
CHANGED
|
@@ -96,8 +96,9 @@ declare function canRegenerateRanklist(ranklist: srk.Ranklist): boolean;
|
|
|
96
96
|
declare function getSortedCalculatedRawSolutions(rows: srk.RanklistRow[]): CalculatedSolutionTetrad[];
|
|
97
97
|
declare function filterSolutionsUntil(solutions: CalculatedSolutionTetrad[], time: srk.TimeDuration): CalculatedSolutionTetrad[];
|
|
98
98
|
declare function sortRows(rows: srk.RanklistRow[]): srk.RanklistRow[];
|
|
99
|
+
declare function calculateProblemStatistics(ranklist: srk.Ranklist): srk.ProblemStatistics[];
|
|
99
100
|
declare function regenerateRanklistBySolutions(originalRanklist: srk.Ranklist, solutions: CalculatedSolutionTetrad[]): srk.Ranklist;
|
|
100
101
|
declare function regenerateRowsByIncrementalSolutions(originalRanklist: srk.Ranklist, solutions: CalculatedSolutionTetrad[]): srk.RanklistRow[];
|
|
101
102
|
declare function convertToStaticRanklist(ranklist: srk.Ranklist): StaticRanklist;
|
|
102
103
|
|
|
103
|
-
export { type CalculatedSolutionTetrad, EnumTheme, MIN_REGEN_SUPPORTED_VERSION, type RankValue, type StaticRanklist, type ThemeColor, alphabetToNumber, canRegenerateRanklist, convertToStaticRanklist, filterSolutionsUntil, formatTimeDuration, getSortedCalculatedRawSolutions, numberToAlphabet, preZeroFill, regenerateRanklistBySolutions, regenerateRowsByIncrementalSolutions, resolveColor, resolveContributor, resolveStyle, resolveText, resolveThemeColor, resolveUserMarkers, secToTimeStr, sortRows };
|
|
104
|
+
export { type CalculatedSolutionTetrad, EnumTheme, MIN_REGEN_SUPPORTED_VERSION, type RankValue, type StaticRanklist, type ThemeColor, alphabetToNumber, calculateProblemStatistics, canRegenerateRanklist, convertToStaticRanklist, filterSolutionsUntil, formatTimeDuration, getSortedCalculatedRawSolutions, numberToAlphabet, preZeroFill, regenerateRanklistBySolutions, regenerateRowsByIncrementalSolutions, resolveColor, resolveContributor, resolveStyle, resolveText, resolveThemeColor, resolveUserMarkers, secToTimeStr, sortRows };
|
package/dist/index.mjs
CHANGED
|
@@ -289,6 +289,27 @@ function cloneDeep(obj) {
|
|
|
289
289
|
}
|
|
290
290
|
return clonedObj;
|
|
291
291
|
}
|
|
292
|
+
function calculateProblemStatistics(ranklist) {
|
|
293
|
+
const problemCount = ranklist.problems.length;
|
|
294
|
+
const problemAcceptedCount = new Array(problemCount).fill(0);
|
|
295
|
+
const problemSubmittedCount = new Array(problemCount).fill(0);
|
|
296
|
+
for (const row of ranklist.rows) {
|
|
297
|
+
for (let i = 0; i < problemCount; i++) {
|
|
298
|
+
const status = row.statuses[i];
|
|
299
|
+
if (!(status == null ? void 0 : status.result)) {
|
|
300
|
+
continue;
|
|
301
|
+
}
|
|
302
|
+
if (status.result === "AC" || status.result === "FB") {
|
|
303
|
+
problemAcceptedCount[i] += 1;
|
|
304
|
+
}
|
|
305
|
+
problemSubmittedCount[i] += status.tries || 0;
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
return ranklist.problems.map((_, index) => ({
|
|
309
|
+
accepted: problemAcceptedCount[index],
|
|
310
|
+
submitted: problemSubmittedCount[index]
|
|
311
|
+
}));
|
|
312
|
+
}
|
|
292
313
|
function regenerateRanklistBySolutions(originalRanklist, solutions) {
|
|
293
314
|
var _a;
|
|
294
315
|
if (!canRegenerateRanklist(originalRanklist)) {
|
|
@@ -296,7 +317,7 @@ function regenerateRanklistBySolutions(originalRanklist, solutions) {
|
|
|
296
317
|
}
|
|
297
318
|
const sorterConfig = {
|
|
298
319
|
penalty: [20, "min"],
|
|
299
|
-
noPenaltyResults: ["FB", "AC", "?", "CE", "UKE", null],
|
|
320
|
+
noPenaltyResults: ["FB", "AC", "?", "NOUT", "CE", "UKE", null],
|
|
300
321
|
timeRounding: "floor",
|
|
301
322
|
...cloneDeep(((_a = originalRanklist.sorter) == null ? void 0 : _a.config) || {})
|
|
302
323
|
};
|
|
@@ -403,7 +424,7 @@ function regenerateRowsByIncrementalSolutions(originalRanklist, solutions) {
|
|
|
403
424
|
}
|
|
404
425
|
const sorterConfig = {
|
|
405
426
|
penalty: [20, "min"],
|
|
406
|
-
noPenaltyResults: ["FB", "AC", "?", "CE", "UKE", null],
|
|
427
|
+
noPenaltyResults: ["FB", "AC", "?", "NOUT", "CE", "UKE", null],
|
|
407
428
|
timeRounding: "floor",
|
|
408
429
|
...cloneDeep(((_a = originalRanklist.sorter) == null ? void 0 : _a.config) || {})
|
|
409
430
|
};
|
|
@@ -552,6 +573,12 @@ function genSeriesCalcFns(series, rows, ranks, officialRanks) {
|
|
|
552
573
|
if (value === void 0) {
|
|
553
574
|
return false;
|
|
554
575
|
}
|
|
576
|
+
if (typeof value === "object") {
|
|
577
|
+
return Object.values(value).some((v) => new RegExp(rule2).test(`${v}`));
|
|
578
|
+
}
|
|
579
|
+
if (Array.isArray(value)) {
|
|
580
|
+
return value.some((v) => new RegExp(rule2).test(`${v}`));
|
|
581
|
+
}
|
|
555
582
|
return new RegExp(rule2).test(`${value}`);
|
|
556
583
|
});
|
|
557
584
|
});
|
|
@@ -717,4 +744,4 @@ function convertToStaticRanklist(ranklist) {
|
|
|
717
744
|
};
|
|
718
745
|
}
|
|
719
746
|
|
|
720
|
-
export { EnumTheme, MIN_REGEN_SUPPORTED_VERSION, alphabetToNumber, canRegenerateRanklist, convertToStaticRanklist, filterSolutionsUntil, formatTimeDuration, getSortedCalculatedRawSolutions, numberToAlphabet, preZeroFill, regenerateRanklistBySolutions, regenerateRowsByIncrementalSolutions, resolveColor, resolveContributor, resolveStyle, resolveText, resolveThemeColor, resolveUserMarkers, secToTimeStr, sortRows };
|
|
747
|
+
export { EnumTheme, MIN_REGEN_SUPPORTED_VERSION, alphabetToNumber, calculateProblemStatistics, canRegenerateRanklist, convertToStaticRanklist, filterSolutionsUntil, formatTimeDuration, getSortedCalculatedRawSolutions, numberToAlphabet, preZeroFill, regenerateRanklistBySolutions, regenerateRowsByIncrementalSolutions, resolveColor, resolveContributor, resolveStyle, resolveText, resolveThemeColor, resolveUserMarkers, secToTimeStr, sortRows };
|