core: fix pid sort

This commit is contained in:
undefined committed 2020-11-23 22:13:43 +08:00
1 parent 19ebf5e9a8
commit 65094e53b6
3 files changed
+5 -2

No files matched your search

+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "hydrooj", "name": "hydrooj",
"version": "2.13.53", "version": "2.13.54",
"bin": "bin/hydrooj.js", "bin": "bin/hydrooj.js",
"main": "dist/loader.js", "main": "dist/loader.js",
"typings": "dist/loader.d.ts", "typings": "dist/loader.d.ts",
-1
View File
@@ -82,7 +82,6 @@ export async function add(
tag: string[] = [], category: string[] = [], data: ProblemDataSource = null, hidden = false, tag: string[] = [], category: string[] = [], data: ProblemDataSource = null, hidden = false,
) { ) {
const pidCounter = await domain.inc(domainId, 'pidCounter', 1); const pidCounter = await domain.inc(domainId, 'pidCounter', 1);
if (!pid) pid = pidCounter.toString();
return await document.add( return await document.add(
domainId, content, owner, document.TYPE_PROBLEM, pidCounter, null, null, domainId, content, owner, document.TYPE_PROBLEM, pidCounter, null, null,
{ {
+4
View File
@@ -1,6 +1,7 @@
/* eslint-disable no-await-in-loop */ /* eslint-disable no-await-in-loop */
import * as domain from './model/domain'; import * as domain from './model/domain';
import * as document from './model/document'; import * as document from './model/document';
import { db } from './service/db';
type UpgradeScript = () => Promise<void>; type UpgradeScript = () => Promise<void>;
@@ -29,6 +30,9 @@ const scripts: UpgradeScript[] = [
if (bulk.length) await bulk.execute(); if (bulk.length) await bulk.execute();
} }
}, },
async function _2_3() {
await db.collection('document').updateMany({ pid: /^\d+$/i }, { $unset: { pid: '' } });
},
]; ];
export = scripts; export = scripts;