manually pull parts out of 57f2a50fb7

This commit is contained in:
Shish 2019-07-07 11:16:47 +01:00
parent f8a08a7aae
commit 4136b1bb6b

View File

@ -525,23 +525,20 @@ class TagList extends Extension
} }
$tag_id_list = join(', ', $tag_id_array); $tag_id_list = join(', ', $tag_id_array);
if (count($tag_id_array) > 5) { if (count($tag_id_array) > 5 || count($tag_id_array) == 0) {
return; return;
} }
if ($tags_ok) { if ($tags_ok) {
$query = " $query = "
SELECT t2.tag AS tag, COUNT(it2.image_id) AS calc_count SELECT t2.tag AS tag, COUNT(it2.image_id) AS calc_count
FROM FROM image_tags AS it1 -- Got other images with the same tags
image_tags AS it1, -- Get the tags from those images, except those the same as the starting tags
image_tags AS it2, INNER JOIN image_tags AS it2 ON it1.image_id=it2.image_id AND it2.tag_id NOT IN($tag_id_list)
tags AS t1, -- And filter out anything starting with tagme
tags AS t2 INNER JOIN tags AS t2 ON it2.tag_id = t2.id AND t2.tag NOT LIKE 'tagme%'
WHERE WHERE
t1.id IN($tag_id_list) it1.tag_id IN($tag_id_list)
AND it1.image_id=it2.image_id
AND it1.tag_id = t1.id
AND it2.tag_id = t2.id
GROUP BY t2.tag GROUP BY t2.tag
ORDER BY calc_count ORDER BY calc_count
DESC LIMIT :limit DESC LIMIT :limit