core: fix sortable handle

This commit is contained in:
undefined committed 2021-11-29 22:56:03 +08:00
1 parent 4918f41eac
commit 51527c7f79
3 files changed
+3 -3

No files matched your search

+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "hydrooj",
"version": "3.1.41",
"version": "3.1.42",
"bin": "bin/hydrooj.js",
"main": "src/loader",
"module": "src/loader",
+1 -1
View File
@@ -22,7 +22,7 @@ export interface ProblemDoc extends Document { }
export type Field = keyof ProblemDoc;
function sortable(source: string) {
return source.replace(/(\d+)/g, (str) => '0'.repeat(6 - str.length) + str);
return source.replace(/(\d+)/g, (str) => (str.length >= 6 ? str : ('0'.repeat(6 - str.length) + str)));
}
export class ProblemModel {
+1 -1
View File
@@ -652,7 +652,7 @@ const scripts: UpgradeScript[] = [
const _FRESH_INSTALL_IGNORE = 1;
const bulk = db.collection('document').initializeUnorderedBulkOp();
function sortable(source: string) {
return source.replace(/(\d+)/g, (str) => '0'.repeat(6 - str.length) + str);
return source.replace(/(\d+)/g, (str) => (str.length >= 6 ? str : ('0'.repeat(6 - str.length) + str)));
}
await iterateAllProblem(['pid', '_id'], async (pdoc) => {
bulk.find({ _id: pdoc._id }).updateOne({ $set: { sort: sortable(pdoc.pid || `P${pdoc.docId}`) } });