mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
core: schemastery validator
This commit is contained in:
1 parent
2d4d99c80c
commit
1f113e7a08
17 files changed
+145
-136
No files matched your search
@@ -1,6 +1,7 @@
|
||||
/* eslint-disable no-await-in-loop */
|
||||
import { omit } from 'lodash';
|
||||
import { Index, MeiliSearch } from 'meilisearch';
|
||||
import { addScript, Schema } from 'hydrooj';
|
||||
import DomainModel from 'hydrooj/src/model/domain';
|
||||
import ProblemModel from 'hydrooj/src/model/problem';
|
||||
import * as system from 'hydrooj/src/model/system';
|
||||
@@ -50,15 +51,6 @@ global.Hydro.lib.problemSearch = async (domainId, q, opts) => {
|
||||
};
|
||||
};
|
||||
|
||||
export const description = 'Meilisearch reindex';
|
||||
|
||||
export const validate = {
|
||||
$or: [
|
||||
{ domainId: 'string' },
|
||||
{ domainId: 'undefined' },
|
||||
],
|
||||
};
|
||||
|
||||
async function waitForTask(id: number) {
|
||||
// eslint-disable-next-line no-constant-condition
|
||||
while (true) {
|
||||
@@ -109,4 +101,8 @@ export async function run(_, report) {
|
||||
return true;
|
||||
}
|
||||
|
||||
global.Hydro.script.ensureMeiliSearch = { run, description, validate };
|
||||
addScript('ensureMeiliSearch', 'Meilisearch reindex')
|
||||
.args(Schema.object({
|
||||
domainId: Schema.string(),
|
||||
}))
|
||||
.action(run);
|
||||
Reference in new issue
Block a user