core: problem_list: move getByPid to search side

This commit is contained in:
undefined committed 2024-05-20 16:05:38 +08:00
1 parent b1b9645872
commit fcfbb19d2c
2 files changed
+45 -26

No files matched your search

+9 -1
View File
@@ -38,10 +38,18 @@ global.Hydro.lib.problemSearch = async (domainId, q, opts) => {
},
},
});
let hits = res.hits.hits.map((i) => i._id);
if (!opts.skip) {
const pdoc = await ProblemModel.get(domainId, +q || q, ProblemModel.PROJECTION_LIST);
if (pdoc) {
hits = hits.filter((i) => i !== `${pdoc.domainId}/${pdoc.docId}`);
hits.unshift(`${pdoc.domainId}/${pdoc.docId}`);
}
}
return {
countRelation: typeof res.hits.total === 'number' ? 'eq' : res.hits.total.relation,
total: typeof res.hits.total === 'number' ? res.hits.total : res.hits.total.value,
hits: res.hits.hits.map((i) => i._id),
hits,
};
};