mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-18 01:36:08 +08:00
core: fix sortable handle
This commit is contained in:
1 parent
4918f41eac
commit
51527c7f79
3 files changed
+3
-3
No files matched your search
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "hydrooj",
|
||||
"version": "3.1.41",
|
||||
"version": "3.1.42",
|
||||
"bin": "bin/hydrooj.js",
|
||||
"main": "src/loader",
|
||||
"module": "src/loader",
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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}`) } });
|
||||
|
||||
Reference in new issue
Block a user