core: fic category selection

This commit is contained in:
undefined committed 2022-05-12 11:28:35 +08:00
1 parent 69c6a34c34
commit fdcf06c373
2 files changed
+3 -3

No files matched your search

+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "hydrooj",
"version": "3.13.3",
"version": "3.13.4",
"bin": "bin/hydrooj.js",
"main": "src/loader",
"module": "src/loader",
+2 -2
View File
@@ -149,7 +149,7 @@ export class ProblemMainHandler extends ProblemHandler {
let pcountRelation = 'eq';
const category = flattenDeep(decodeURIComponent(q).split(' ')
.filter((i) => i.startsWith('category:'))
.map((i) => i.split(':')[1]?.split(',')));
.map((i) => i.split('category:')[1]?.split(',')));
const text = q.split(' ').filter((i) => !i.startsWith('category:')).join(' ');
if (category.length) query.$and = category.map((tag) => ({ tag }));
if (text) category.push(text);
@@ -288,7 +288,7 @@ export class ProblemRandomHandler extends ProblemHandler {
async get(domainId: string, qs = '') {
const category = flattenDeep(decodeURIComponent(qs).split(' ')
.filter((i) => i.startsWith('category:'))
.map((i) => i.split(':')[1]?.split(',')));
.map((i) => i.split('category:')[1]?.split(',')));
console.log(qs, category);
const q = buildQuery(this.user);
if (category.length) q.$and = category.map((tag) => ({ tag }));