@algoux/standard-ranklist-utils 0.1.0 → 0.1.1
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/LICENSE +21 -0
- package/README.md +31 -1
- package/dist/ranklist.js +41 -6
- package/package.json +6 -4
- package/dist/dev.d.ts +0 -0
- package/dist/dev.js +0 -2
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023 algoUX
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1 +1,31 @@
|
|
|
1
|
-
#
|
|
1
|
+
# standard-ranklist-utils
|
|
2
|
+
|
|
3
|
+
Utilities for standard ranklist.
|
|
4
|
+
|
|
5
|
+
## Utilities
|
|
6
|
+
|
|
7
|
+
### formatters
|
|
8
|
+
|
|
9
|
+
- `formatTimeDuration`
|
|
10
|
+
- `preZeroFill`
|
|
11
|
+
- `secToTimeStr`
|
|
12
|
+
- `numberToAlphabet`
|
|
13
|
+
- `alphabetToNumber`
|
|
14
|
+
|
|
15
|
+
### resolvers
|
|
16
|
+
|
|
17
|
+
- `resolveText`
|
|
18
|
+
- `resolveContributor`
|
|
19
|
+
- `resolveColor`
|
|
20
|
+
- `resolveThemeColor`
|
|
21
|
+
- `resolveStyle`
|
|
22
|
+
|
|
23
|
+
### ranklist
|
|
24
|
+
|
|
25
|
+
- `canRegenerateRanklist`
|
|
26
|
+
- `getSortedCalculatedRawSolutions`
|
|
27
|
+
- `filterSolutionsUntil`
|
|
28
|
+
- `sortRows`
|
|
29
|
+
- `regenerateRanklistBySolutions`
|
|
30
|
+
- `regenerateRowsByIncrementalSolutions`
|
|
31
|
+
- `convertToStaticRanklist`
|
package/dist/ranklist.js
CHANGED
|
@@ -329,11 +329,46 @@ function genSeriesCalcFns(series, rows, ranks, officialRanks) {
|
|
|
329
329
|
}
|
|
330
330
|
case 'ICPC': {
|
|
331
331
|
const options = rule.options;
|
|
332
|
+
let filteredRows = rows.filter((row) => row.user.official === undefined || row.user.official === true);
|
|
333
|
+
let filteredOfficialRanks = [...officialRanks];
|
|
334
|
+
if (options.filter) {
|
|
335
|
+
if (Array.isArray(options.filter.byUserFields) && options.filter.byUserFields.length) {
|
|
336
|
+
const currentFilteredRows = [];
|
|
337
|
+
filteredOfficialRanks = filteredOfficialRanks.map(() => null);
|
|
338
|
+
let currentOfficialRank = 0;
|
|
339
|
+
let currentOfficialRankOld = 0;
|
|
340
|
+
rows.forEach((row, index) => {
|
|
341
|
+
const shouldInclude = options.filter.byUserFields.every((filter) => {
|
|
342
|
+
const { field, rule } = filter;
|
|
343
|
+
const value = row.user[field];
|
|
344
|
+
if (value === undefined) {
|
|
345
|
+
return false;
|
|
346
|
+
}
|
|
347
|
+
return new RegExp(rule).test(`${value}`);
|
|
348
|
+
});
|
|
349
|
+
if (shouldInclude) {
|
|
350
|
+
currentFilteredRows.push(row);
|
|
351
|
+
const oldRank = officialRanks[index];
|
|
352
|
+
if (oldRank !== null) {
|
|
353
|
+
if (currentOfficialRankOld !== oldRank) {
|
|
354
|
+
currentOfficialRank++;
|
|
355
|
+
currentOfficialRankOld = oldRank;
|
|
356
|
+
}
|
|
357
|
+
filteredOfficialRanks[index] = currentOfficialRank;
|
|
358
|
+
}
|
|
359
|
+
else {
|
|
360
|
+
filteredOfficialRanks[index] = null;
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
});
|
|
364
|
+
filteredRows = currentFilteredRows;
|
|
365
|
+
}
|
|
366
|
+
}
|
|
332
367
|
const usingEndpointRules = [];
|
|
333
368
|
let noTied = false;
|
|
334
369
|
if (options.ratio) {
|
|
335
370
|
const { value, rounding = 'ceil', denominator = 'all' } = options.ratio;
|
|
336
|
-
const officialRows =
|
|
371
|
+
const officialRows = filteredRows;
|
|
337
372
|
let total = denominator === 'submitted'
|
|
338
373
|
? officialRows.filter((row) => !row.statuses.every((s) => s.result === null)).length
|
|
339
374
|
: officialRows.length;
|
|
@@ -367,11 +402,11 @@ function genSeriesCalcFns(series, rows, ranks, officialRanks) {
|
|
|
367
402
|
}
|
|
368
403
|
const officialRanksNoTied = [];
|
|
369
404
|
let currentOfficialRank = 0;
|
|
370
|
-
for (let i = 0; i <
|
|
371
|
-
officialRanksNoTied.push(
|
|
405
|
+
for (let i = 0; i < filteredOfficialRanks.length; i++) {
|
|
406
|
+
officialRanksNoTied.push(filteredOfficialRanks[i] === null ? null : ++currentOfficialRank);
|
|
372
407
|
}
|
|
373
408
|
return (row, index) => {
|
|
374
|
-
if (row.user.official === false) {
|
|
409
|
+
if (row.user.official === false || !filteredRows.find((r) => r.user.id === row.user.id)) {
|
|
375
410
|
return {
|
|
376
411
|
rank: null,
|
|
377
412
|
segmentIndex: null,
|
|
@@ -380,10 +415,10 @@ function genSeriesCalcFns(series, rows, ranks, officialRanks) {
|
|
|
380
415
|
const usingSegmentIndex = (seriesConfig.segments || []).findIndex((_, segIndex) => {
|
|
381
416
|
return usingEndpointRules
|
|
382
417
|
.map((e) => e[segIndex])
|
|
383
|
-
.every((endpoints) => (noTied ? officialRanksNoTied :
|
|
418
|
+
.every((endpoints) => (noTied ? officialRanksNoTied : filteredOfficialRanks)[index] <= endpoints);
|
|
384
419
|
});
|
|
385
420
|
return {
|
|
386
|
-
rank:
|
|
421
|
+
rank: filteredOfficialRanks[index],
|
|
387
422
|
segmentIndex: usingSegmentIndex > -1 ? usingSegmentIndex : null,
|
|
388
423
|
};
|
|
389
424
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@algoux/standard-ranklist-utils",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"author": "bLue",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"standard ranklist",
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
],
|
|
16
16
|
"scripts": {
|
|
17
17
|
"dev": "NODE_OPTIONS='--es-module-specifier-resolution=node' ts-node --transpile-only src/index.ts",
|
|
18
|
-
"build": "tsc"
|
|
18
|
+
"build": "rimraf dist && tsc"
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
21
|
"bcp-47-match": "^2.0.2",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"textcolor": "^1.0.2"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
|
-
"@algoux/standard-ranklist": "^0.3.
|
|
27
|
+
"@algoux/standard-ranklist": "^0.3.3",
|
|
28
28
|
"@types/node": "^16.18.38",
|
|
29
29
|
"@types/semver": "^7.5.0",
|
|
30
30
|
"@typescript-eslint/eslint-plugin": "^5.61.0",
|
|
@@ -32,6 +32,7 @@
|
|
|
32
32
|
"eslint": "^8.44.0",
|
|
33
33
|
"eslint-config-alloy": "^4.0.0",
|
|
34
34
|
"prettier": "^2.7.1",
|
|
35
|
+
"rimraf": "^5.0.1",
|
|
35
36
|
"ts-node": "^10.9.1",
|
|
36
37
|
"typescript": "^4.9.5"
|
|
37
38
|
},
|
|
@@ -46,5 +47,6 @@
|
|
|
46
47
|
"bugs": {
|
|
47
48
|
"url": "https://github.com/algoux/standard-ranklist-utils/issues"
|
|
48
49
|
},
|
|
49
|
-
"homepage": "https://github.com/algoux/standard-ranklist-utils#readme"
|
|
50
|
+
"homepage": "https://github.com/algoux/standard-ranklist-utils#readme",
|
|
51
|
+
"srkSupportedVersions": ">=0.3.0 <=0.3.3"
|
|
50
52
|
}
|
package/dist/dev.d.ts
DELETED
|
File without changes
|
package/dist/dev.js
DELETED