mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
sonic: allow limit arg
This commit is contained in:
1 parent
77e592daf3
commit
e02bbd970e
2 files changed
+4
-5
No files matched your search
@@ -19,9 +19,8 @@ bus.on('problem/del', async (domainId, docId) => {
|
|||||||
await sonic.flusho('problem', `${domainId}@content`, docId.toString());
|
await sonic.flusho('problem', `${domainId}@content`, docId.toString());
|
||||||
});
|
});
|
||||||
|
|
||||||
global.Hydro.lib.problemSearch = async (domainId: string, query: string) => {
|
global.Hydro.lib.problemSearch = async (domainId: string, query: string, limit = system.get('pagination.problem')) => {
|
||||||
const c = system.get('pagination.problem');
|
const docIds = await sonic.query('problem', `${domainId}@title`, query, { limit });
|
||||||
const docIds = await sonic.query('problem', `${domainId}@title`, query, { limit: c });
|
if (limit - docIds.length > 0) docIds.push(...await sonic.query('problem', `${domainId}@content`, query, { limit: limit - docIds.length }));
|
||||||
if (c - docIds.length > 0) docIds.push(...await sonic.query('problem', `${domainId}@content`, query, { limit: c - docIds.length }));
|
|
||||||
return docIds.map(Number);
|
return docIds.map(Number);
|
||||||
};
|
};
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@hydrooj/sonic",
|
"name": "@hydrooj/sonic",
|
||||||
"version": "1.0.3",
|
"version": "1.0.4",
|
||||||
"description": "Sonic search service",
|
"description": "Sonic search service",
|
||||||
"main": "service.js",
|
"main": "service.js",
|
||||||
"typings": "service.d.ts",
|
"typings": "service.d.ts",
|
||||||
|
|||||||
Reference in new issue
Block a user