mirror of
https://github.com/discourse/discourse.git
synced 2025-05-22 18:41:09 +08:00
Add rubocop to our build. (#5004)
This commit is contained in:
@ -11,15 +11,14 @@ class SuggestedTopicsBuilder
|
||||
@results = []
|
||||
end
|
||||
|
||||
|
||||
def add_results(results, priority=:low)
|
||||
def add_results(results, priority = :low)
|
||||
|
||||
# WARNING .blank? will execute an Active Record query
|
||||
return unless results
|
||||
|
||||
# Only add results if we don't have those topic ids already
|
||||
results = results.where('topics.id NOT IN (?)', @excluded_topic_ids)
|
||||
.where(visible: true)
|
||||
.where(visible: true)
|
||||
|
||||
# If limit suggested to category is enabled, restrict to that category
|
||||
if @category_id && SiteSetting.limit_suggested_to_category?
|
||||
@ -29,8 +28,8 @@ class SuggestedTopicsBuilder
|
||||
|
||||
unless results.empty?
|
||||
# Keep track of the ids we've added
|
||||
@excluded_topic_ids.concat results.map {|r| r.id}
|
||||
splice_results(results,priority)
|
||||
@excluded_topic_ids.concat results.map { |r| r.id }
|
||||
splice_results(results, priority)
|
||||
end
|
||||
end
|
||||
|
||||
@ -40,7 +39,7 @@ class SuggestedTopicsBuilder
|
||||
# Topics from category @category_id need to be first in the list, all others after.
|
||||
|
||||
other_category_index = @results.index { |r| r.category_id != @category_id }
|
||||
category_results, other_category_results = results.partition{ |r| r.category_id == @category_id }
|
||||
category_results, other_category_results = results.partition { |r| r.category_id == @category_id }
|
||||
|
||||
if other_category_index
|
||||
@results.insert other_category_index, *category_results
|
||||
@ -66,7 +65,7 @@ class SuggestedTopicsBuilder
|
||||
end
|
||||
|
||||
def category_results_left
|
||||
SiteSetting.suggested_topics - @results.count{|r| r.category_id == @category_id}
|
||||
SiteSetting.suggested_topics - @results.count { |r| r.category_id == @category_id }
|
||||
end
|
||||
|
||||
def size
|
||||
|
Reference in New Issue
Block a user