Fix a bug where the search pages did not show comments
When comments were added, the search page was not modified appropriately.
This commit is contained in:
parent
5c5637ff40
commit
f83bf55d3f
|
@ -54,7 +54,8 @@ local function search_get(req)
|
|||
author = row[4],
|
||||
posted = os.date("%B %d %Y",tonumber(row[5])),
|
||||
tags = libtags.get(row[1]),
|
||||
hits = row[6]
|
||||
hits = row[6],
|
||||
ncomments = row[7]
|
||||
})
|
||||
end
|
||||
local ret = pages.search{
|
||||
|
|
|
@ -4,9 +4,11 @@ SELECT
|
|||
posts.isanon,
|
||||
authors.name,
|
||||
posts.post_time,
|
||||
posts.views
|
||||
posts.views,
|
||||
COUNT(comments.id)
|
||||
FROM
|
||||
posts,authors
|
||||
LEFT JOIN comments ON comments.postid = posts.id
|
||||
WHERE
|
||||
authors.id = posts.authorid
|
||||
AND posts.unlisted = 0
|
||||
|
@ -25,6 +27,8 @@ WHERE
|
|||
<% end -%>
|
||||
<% end -%>
|
||||
<% end -%>
|
||||
GROUP BY
|
||||
posts.id
|
||||
<% for _,tag in pairs(result.tags) do -%>
|
||||
INTERSECT
|
||||
SELECT
|
||||
|
@ -33,9 +37,11 @@ SELECT
|
|||
posts.isanon,
|
||||
authors.name,
|
||||
posts.post_time,
|
||||
posts.views
|
||||
posts.views,
|
||||
COUNT(comments.id)
|
||||
FROM
|
||||
posts,authors,tags
|
||||
LEFT JOIN comments ON comments.postid = posts.id
|
||||
WHERE
|
||||
posts.authorid = authors.id
|
||||
AND tags.postid = posts.id
|
||||
|
@ -43,4 +49,6 @@ WHERE
|
|||
<% n = (n == "-" and "NOT" or "") -%>
|
||||
AND <%= n %> tags.tag = ?
|
||||
<% end -%>
|
||||
GROUP BY
|
||||
posts.id
|
||||
;
|
||||
|
|
Loading…
Reference in New Issue