sonic: allow limit arg

pull/148/head
undefined 3 years ago
parent 77e592daf3
commit e02bbd970e

@ -19,9 +19,8 @@ bus.on('problem/del', async (domainId, docId) => {
await sonic.flusho('problem', `${domainId}@content`, docId.toString());
});
global.Hydro.lib.problemSearch = async (domainId: string, query: string) => {
const c = system.get('pagination.problem');
const docIds = await sonic.query('problem', `${domainId}@title`, query, { limit: c });
if (c - docIds.length > 0) docIds.push(...await sonic.query('problem', `${domainId}@content`, query, { limit: c - docIds.length }));
global.Hydro.lib.problemSearch = async (domainId: string, query: string, limit = system.get('pagination.problem')) => {
const docIds = await sonic.query('problem', `${domainId}@title`, query, { limit });
if (limit - docIds.length > 0) docIds.push(...await sonic.query('problem', `${domainId}@content`, query, { limit: limit - docIds.length }));
return docIds.map(Number);
};

@ -1,6 +1,6 @@
{
"name": "@hydrooj/sonic",
"version": "1.0.3",
"version": "1.0.4",
"description": "Sonic search service",
"main": "service.js",
"typings": "service.d.ts",

Loading…
Cancel
Save