core: drop global.Hydro.lib

This commit is contained in:
undefined committed 2025-03-10 12:31:25 +08:00
1 parent 1165bfff5b
commit 6ff66f2efc
17 files changed
+31 -45

No files matched your search

+3 -2
View File
@@ -19,7 +19,7 @@ const processDocument = (doc: Partial<ProblemDoc>) => {
return _.omit(doc, indexOmit);
};
global.Hydro.lib.problemSearch = async (domainId, q, opts) => {
async function problemSearch(domainId, q, opts) {
const allowedSize = SystemModel.get('elasic-search.indexSize') || 10000;
const size = opts?.limit || SystemModel.get('pagination.problem');
const from = Math.min(allowedSize - size, opts?.skip || 0);
@@ -56,7 +56,7 @@ global.Hydro.lib.problemSearch = async (domainId, q, opts) => {
total: typeof res.hits.total === 'number' ? res.hits.total : res.hits.total.value,
hits: Array.from(new Set(hits)),
};
};
}
async function run({ domainId }, report) {
try {
@@ -109,4 +109,5 @@ export const apply = (ctx: Context) => {
}),
run,
);
ctx.provideModule('problemSearch', 'elastic', problemSearch);
};