DEV: Remove array_agg from search orders that does not need it.

This commit is contained in:
Guo Xiang Tan 2020-08-21 14:39:07 +08:00
parent 7833853cf1
commit 0684118008
No known key found for this signature in database
GPG Key ID: FBD110179AAC1F20
1 changed files with 5 additions and 5 deletions

View File

@ -933,33 +933,33 @@ class Search
if aggregate_search
aggregate_relation = aggregate_relation
.select(
"(ARRAY_AGG(subquery.post_number ORDER BY subquery.created_at DESC))[1] post_number",
"MAX(subquery.post_number) post_number",
"MAX(subquery.created_at) created_at"
)
.order("created_at DESC")
end
elsif @order == :latest_topic
posts = posts.order("topic_created_at DESC")
posts = posts.order("topics.created_at DESC")
if aggregate_search
posts = posts.select("topics.created_at topic_created_at")
aggregate_relation = aggregate_relation
.select(
"(ARRAY_AGG(subquery.post_number ORDER BY subquery.topic_created_at DESC))[1] post_number",
"MIN(subquery.post_number) post_number",
"MAX(subquery.topic_created_at) topic_created_at"
)
.order("topic_created_at DESC")
end
elsif @order == :views
posts = posts.order("topic_views DESC")
posts = posts.order("topics.views DESC")
if aggregate_search
posts = posts.select("topics.views topic_views")
aggregate_relation = aggregate_relation
.select(
"(ARRAY_AGG(subquery.post_number ORDER BY subquery.topic_views DESC))[1] post_number",
"MIN(subquery.post_number) post_number",
"MAX(subquery.topic_views) topic_views"
)
.order("topic_views DESC")