core: schemastery validator

This commit is contained in:
undefined committed 2022-07-31 23:53:49 +08:00
1 parent 2d4d99c80c
commit 1f113e7a08
17 files changed
+145 -136

No files matched your search

+2 -3
View File
@@ -1,9 +1,8 @@
{
"name": "@hydrooj/sonic",
"version": "1.2.6",
"version": "1.2.7",
"description": "Sonic search service",
"main": "service.js",
"typings": "service.d.ts",
"main": "service.ts",
"preferUnplugged": true,
"repository": "https://github.com/hydro-dev/Hydro.git",
"author": "undefined <i@undefined.moe>",
+7 -11
View File
@@ -1,10 +1,9 @@
import { addScript, Schema } from 'hydrooj';
import DomainModel from 'hydrooj/src/model/domain';
import { iterateAllProblem, iterateAllProblemInDomain } from 'hydrooj/src/pipelineUtils';
import sonic from './service';
export const description = 'Sonic problem search re-index';
export async function run({ domainId }, report) {
async function run({ domainId }, report) {
if (domainId) await sonic.flushb('problem', domainId);
else await sonic.flushc('problem');
let i = 0;
@@ -29,11 +28,8 @@ export async function run({ domainId }, report) {
return true;
}
export const validate = {
$or: [
{ domainId: 'string' },
{ domainId: 'undefined' },
],
};
global.Hydro.script.ensureSonicSearch = { run, description, validate };
addScript('ensureSonicSearch', 'Sonic problem search re-index')
.args(Schema.object({
domainId: Schema.string(),
}))
.action(run);