mirror of
https://github.com/discourse/discourse.git
synced 2024-11-26 07:43:43 +08:00
Consistency in SQL style
This commit is contained in:
parent
3f7a711dd6
commit
b7a76cbd24
|
@ -100,7 +100,7 @@ module Search
|
|||
|
||||
db_result = []
|
||||
[user_query_sql, category_query_sql, topic_query_sql].each do |sql|
|
||||
sql << " limit " << Search.per_facet.to_s
|
||||
sql << " LIMIT " << Search.per_facet.to_s
|
||||
db_result += ActiveRecord::Base.exec_sql(sql , query: terms.join(" & ")).to_a
|
||||
end
|
||||
end
|
||||
|
@ -110,11 +110,13 @@ module Search
|
|||
expected_topics = 0
|
||||
expected_topics = Search.facets.size unless type_filter.present?
|
||||
expected_topics = Search.per_facet * Search.facets.size if type_filter == 'topic'
|
||||
|
||||
if expected_topics > 0
|
||||
db_result.each do |row|
|
||||
expected_topics -= 1 if row['type'] == 'topic'
|
||||
end
|
||||
end
|
||||
|
||||
if expected_topics > 0
|
||||
tmp = ActiveRecord::Base.exec_sql "#{post_query_sql} limit :per_facet",
|
||||
query: terms.join(" & "), per_facet: expected_topics * 3
|
||||
|
@ -134,11 +136,9 @@ module Search
|
|||
db_result += tmp[0..expected_topics-1]
|
||||
end
|
||||
|
||||
|
||||
# Group the results by type
|
||||
grouped = {}
|
||||
db_result.each do |row|
|
||||
|
||||
type = row.delete('type')
|
||||
|
||||
# Add the slug for topics
|
||||
|
|
Loading…
Reference in New Issue
Block a user