forked from f0ck/f0ckv2
remove invalid results
This commit is contained in:
parent
5318486bc1
commit
8ed6bb4f1f
@ -187,7 +187,7 @@ export default router => {
|
|||||||
return res.json(q, tagname === newtag ? 200 : 201); // created (modified)
|
return res.json(q, tagname === newtag ? 200 : 201); // created (modified)
|
||||||
});
|
});
|
||||||
|
|
||||||
group.get(/\/admin\/tags\/suggest$/, lib.loggedin, async (req, res) => {
|
group.get(/\/admin\/tags\/suggest$/, async (req, res) => {
|
||||||
const reply = {
|
const reply = {
|
||||||
success: false,
|
success: false,
|
||||||
suggestions: {}
|
suggestions: {}
|
||||||
@ -202,7 +202,7 @@ export default router => {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
const q = await db`
|
const q = await db`
|
||||||
select tag, count(tags_assign.tag_id) as tagged
|
select tag, CAST(coalesce(count(tags_assign.tag_id), '0') AS integer) AS tagged
|
||||||
from "tags"
|
from "tags"
|
||||||
left join "tags_assign" on "tags_assign".tag_id = "tags".id
|
left join "tags_assign" on "tags_assign".tag_id = "tags".id
|
||||||
where normalized like '%' || slugify(${searchString}) || '%'
|
where normalized like '%' || slugify(${searchString}) || '%'
|
||||||
@ -211,7 +211,7 @@ export default router => {
|
|||||||
limit 15
|
limit 15
|
||||||
`;
|
`;
|
||||||
reply.success = true;
|
reply.success = true;
|
||||||
reply.suggestions = search(q, searchString);
|
reply.suggestions = search(q, searchString).filter(e => typeof e === 'object');
|
||||||
} catch(err) {
|
} catch(err) {
|
||||||
reply.error = err.msg;
|
reply.error = err.msg;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user