@algoux/standard-ranklist-utils 0.2.7 → 0.2.9
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 +25 -3
- package/dist/index.d.cts +2 -1
- package/dist/index.d.mts +2 -1
- package/dist/index.mjs +25 -4
- 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
|
};
|
|
@@ -574,9 +595,9 @@ function genSeriesCalcFns(series, rows, ranks, officialRanks) {
|
|
|
574
595
|
const shouldInclude = filterTests.every((test) => test(row));
|
|
575
596
|
if (shouldInclude) {
|
|
576
597
|
currentFilteredRows.push(row);
|
|
577
|
-
currentRank++;
|
|
578
598
|
const oldRank = officialRanks[index];
|
|
579
599
|
if (oldRank !== null) {
|
|
600
|
+
currentRank++;
|
|
580
601
|
if (currentOfficialRankOld !== oldRank) {
|
|
581
602
|
currentOfficialRank2 = currentRank;
|
|
582
603
|
currentOfficialRankOld = oldRank;
|
|
@@ -722,6 +743,7 @@ function convertToStaticRanklist(ranklist) {
|
|
|
722
743
|
exports.EnumTheme = EnumTheme;
|
|
723
744
|
exports.MIN_REGEN_SUPPORTED_VERSION = MIN_REGEN_SUPPORTED_VERSION;
|
|
724
745
|
exports.alphabetToNumber = alphabetToNumber;
|
|
746
|
+
exports.calculateProblemStatistics = calculateProblemStatistics;
|
|
725
747
|
exports.canRegenerateRanklist = canRegenerateRanklist;
|
|
726
748
|
exports.convertToStaticRanklist = convertToStaticRanklist;
|
|
727
749
|
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
|
};
|
|
@@ -572,9 +593,9 @@ function genSeriesCalcFns(series, rows, ranks, officialRanks) {
|
|
|
572
593
|
const shouldInclude = filterTests.every((test) => test(row));
|
|
573
594
|
if (shouldInclude) {
|
|
574
595
|
currentFilteredRows.push(row);
|
|
575
|
-
currentRank++;
|
|
576
596
|
const oldRank = officialRanks[index];
|
|
577
597
|
if (oldRank !== null) {
|
|
598
|
+
currentRank++;
|
|
578
599
|
if (currentOfficialRankOld !== oldRank) {
|
|
579
600
|
currentOfficialRank2 = currentRank;
|
|
580
601
|
currentOfficialRankOld = oldRank;
|
|
@@ -717,4 +738,4 @@ function convertToStaticRanklist(ranklist) {
|
|
|
717
738
|
};
|
|
718
739
|
}
|
|
719
740
|
|
|
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 };
|
|
741
|
+
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 };
|