Skip to content

Commit 2dbba19

Browse files
committed
Improve the suggested tags
I'm not sure how this came to be so bad, but now it's less bad.
1 parent 6da7a93 commit 2dbba19

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

htdocs/1.1/tag-suggest.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,12 @@
3333

3434
$suggestions = [];
3535
$stmt = $db->prepare(
36-
'SELECT tag FROM tags WHERE tag LIKE CONCAT(?, "%") ORDER BY tag ASC LIMIT 10'
36+
'SELECT tag, COUNT(*) AS number
37+
FROM tags
38+
WHERE tag LIKE CONCAT(?, "%")
39+
GROUP BY tag
40+
ORDER BY number DESC
41+
LIMIT 10'
3742
);
3843
if ($stmt === false) {
3944
api_json_error(500, 'Database error');

0 commit comments

Comments
 (0)