@algoux/standard-ranklist-utils 0.2.5 → 0.2.6
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 +27 -9
- package/dist/index.mjs +27 -9
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -476,6 +476,8 @@ function regenerateRowsByIncrementalSolutions(originalRanklist, solutions) {
|
|
|
476
476
|
return sortRows(rows);
|
|
477
477
|
}
|
|
478
478
|
function genSeriesCalcFns(series, rows, ranks, officialRanks) {
|
|
479
|
+
const filterableUserFields = ["id", "name", "organization"];
|
|
480
|
+
const groupableUserFields = ["id", "name", "organization"];
|
|
479
481
|
const fallbackSeriesCalcFn = () => ({
|
|
480
482
|
rank: null,
|
|
481
483
|
segmentIndex: null
|
|
@@ -514,10 +516,11 @@ function genSeriesCalcFns(series, rows, ranks, officialRanks) {
|
|
|
514
516
|
if (options.includeOfficialOnly && row.user.official === false) {
|
|
515
517
|
return;
|
|
516
518
|
}
|
|
519
|
+
const isValidField = groupableUserFields.includes(field);
|
|
517
520
|
const value = stringify(row.user[field]);
|
|
518
|
-
if (value && !valueSet.has(value)) {
|
|
521
|
+
if (!isValidField || value && !valueSet.has(value)) {
|
|
519
522
|
const outerRank = options.includeOfficialOnly ? officialRanks[index] : ranks[index];
|
|
520
|
-
valueSet.add(value);
|
|
523
|
+
isValidField && valueSet.add(value);
|
|
521
524
|
if (outerRank !== lastOuterRank) {
|
|
522
525
|
lastOuterRank = outerRank;
|
|
523
526
|
lastRank = assignedRanksMap.size + 1;
|
|
@@ -539,20 +542,35 @@ function genSeriesCalcFns(series, rows, ranks, officialRanks) {
|
|
|
539
542
|
let filteredRows = rows.filter((row) => row.user.official === void 0 || row.user.official === true);
|
|
540
543
|
let filteredOfficialRanks = [...officialRanks];
|
|
541
544
|
if (options.filter) {
|
|
545
|
+
const filterTests = [];
|
|
542
546
|
if (Array.isArray(options.filter.byUserFields) && options.filter.byUserFields.length) {
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
const { field, rule: rule2 } = filter;
|
|
547
|
+
options.filter.byUserFields.forEach((filter) => {
|
|
548
|
+
const { field, rule: rule2 } = filter;
|
|
549
|
+
if (!filterableUserFields.includes(field)) {
|
|
550
|
+
return;
|
|
551
|
+
}
|
|
552
|
+
filterTests.push((row) => {
|
|
550
553
|
const value = row.user[field];
|
|
551
554
|
if (value === void 0) {
|
|
552
555
|
return false;
|
|
553
556
|
}
|
|
554
557
|
return new RegExp(rule2).test(`${value}`);
|
|
555
558
|
});
|
|
559
|
+
});
|
|
560
|
+
}
|
|
561
|
+
if (options.filter.byMarker) {
|
|
562
|
+
const marker = options.filter.byMarker;
|
|
563
|
+
filterTests.push((row) => {
|
|
564
|
+
return row.user.marker === marker || Array.isArray(row.user.markers) && row.user.markers.includes(marker);
|
|
565
|
+
});
|
|
566
|
+
}
|
|
567
|
+
if (filterTests.length) {
|
|
568
|
+
const currentFilteredRows = [];
|
|
569
|
+
filteredOfficialRanks = filteredOfficialRanks.map(() => null);
|
|
570
|
+
let currentOfficialRank2 = 0;
|
|
571
|
+
let currentOfficialRankOld = 0;
|
|
572
|
+
rows.forEach((row, index) => {
|
|
573
|
+
const shouldInclude = filterTests.every((test) => test(row));
|
|
556
574
|
if (shouldInclude) {
|
|
557
575
|
currentFilteredRows.push(row);
|
|
558
576
|
const oldRank = officialRanks[index];
|
package/dist/index.mjs
CHANGED
|
@@ -474,6 +474,8 @@ function regenerateRowsByIncrementalSolutions(originalRanklist, solutions) {
|
|
|
474
474
|
return sortRows(rows);
|
|
475
475
|
}
|
|
476
476
|
function genSeriesCalcFns(series, rows, ranks, officialRanks) {
|
|
477
|
+
const filterableUserFields = ["id", "name", "organization"];
|
|
478
|
+
const groupableUserFields = ["id", "name", "organization"];
|
|
477
479
|
const fallbackSeriesCalcFn = () => ({
|
|
478
480
|
rank: null,
|
|
479
481
|
segmentIndex: null
|
|
@@ -512,10 +514,11 @@ function genSeriesCalcFns(series, rows, ranks, officialRanks) {
|
|
|
512
514
|
if (options.includeOfficialOnly && row.user.official === false) {
|
|
513
515
|
return;
|
|
514
516
|
}
|
|
517
|
+
const isValidField = groupableUserFields.includes(field);
|
|
515
518
|
const value = stringify(row.user[field]);
|
|
516
|
-
if (value && !valueSet.has(value)) {
|
|
519
|
+
if (!isValidField || value && !valueSet.has(value)) {
|
|
517
520
|
const outerRank = options.includeOfficialOnly ? officialRanks[index] : ranks[index];
|
|
518
|
-
valueSet.add(value);
|
|
521
|
+
isValidField && valueSet.add(value);
|
|
519
522
|
if (outerRank !== lastOuterRank) {
|
|
520
523
|
lastOuterRank = outerRank;
|
|
521
524
|
lastRank = assignedRanksMap.size + 1;
|
|
@@ -537,20 +540,35 @@ function genSeriesCalcFns(series, rows, ranks, officialRanks) {
|
|
|
537
540
|
let filteredRows = rows.filter((row) => row.user.official === void 0 || row.user.official === true);
|
|
538
541
|
let filteredOfficialRanks = [...officialRanks];
|
|
539
542
|
if (options.filter) {
|
|
543
|
+
const filterTests = [];
|
|
540
544
|
if (Array.isArray(options.filter.byUserFields) && options.filter.byUserFields.length) {
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
const { field, rule: rule2 } = filter;
|
|
545
|
+
options.filter.byUserFields.forEach((filter) => {
|
|
546
|
+
const { field, rule: rule2 } = filter;
|
|
547
|
+
if (!filterableUserFields.includes(field)) {
|
|
548
|
+
return;
|
|
549
|
+
}
|
|
550
|
+
filterTests.push((row) => {
|
|
548
551
|
const value = row.user[field];
|
|
549
552
|
if (value === void 0) {
|
|
550
553
|
return false;
|
|
551
554
|
}
|
|
552
555
|
return new RegExp(rule2).test(`${value}`);
|
|
553
556
|
});
|
|
557
|
+
});
|
|
558
|
+
}
|
|
559
|
+
if (options.filter.byMarker) {
|
|
560
|
+
const marker = options.filter.byMarker;
|
|
561
|
+
filterTests.push((row) => {
|
|
562
|
+
return row.user.marker === marker || Array.isArray(row.user.markers) && row.user.markers.includes(marker);
|
|
563
|
+
});
|
|
564
|
+
}
|
|
565
|
+
if (filterTests.length) {
|
|
566
|
+
const currentFilteredRows = [];
|
|
567
|
+
filteredOfficialRanks = filteredOfficialRanks.map(() => null);
|
|
568
|
+
let currentOfficialRank2 = 0;
|
|
569
|
+
let currentOfficialRankOld = 0;
|
|
570
|
+
rows.forEach((row, index) => {
|
|
571
|
+
const shouldInclude = filterTests.every((test) => test(row));
|
|
554
572
|
if (shouldInclude) {
|
|
555
573
|
currentFilteredRows.push(row);
|
|
556
574
|
const oldRank = officialRanks[index];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@algoux/standard-ranklist-utils",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.6",
|
|
4
4
|
"author": "bLue",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"standard ranklist",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"textcolor": "^1.0.2"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
|
-
"@algoux/standard-ranklist": "^0.3.
|
|
39
|
+
"@algoux/standard-ranklist": "^0.3.9",
|
|
40
40
|
"@types/node": "^16.18.38",
|
|
41
41
|
"@typescript-eslint/eslint-plugin": "^5.61.0",
|
|
42
42
|
"@typescript-eslint/parser": "^5.61.0",
|