mirror of
https://github.com/discourse/discourse.git
synced 2025-05-30 07:11:34 +08:00
Fix all the errors to get our tests green on Rails 5.1.
This commit is contained in:
@ -266,9 +266,7 @@ class TopicQuery
|
||||
|
||||
def list_category_topic_ids(category)
|
||||
query = default_results(category: category.id)
|
||||
pinned_ids = query.where('pinned_at IS NOT NULL AND category_id = ?', category.id)
|
||||
.limit(nil)
|
||||
.order('pinned_at DESC').pluck(:id)
|
||||
pinned_ids = query.where('pinned_at IS NOT NULL AND category_id = ?', category.id).limit(nil).order('pinned_at DESC').pluck(:id)
|
||||
non_pinned_ids = query.where('pinned_at IS NULL OR category_id <> ?', category.id).pluck(:id)
|
||||
(pinned_ids + non_pinned_ids)
|
||||
end
|
||||
@ -311,7 +309,7 @@ class TopicQuery
|
||||
if page == 0
|
||||
(pinned_topics + unpinned_topics)[0...limit] if limit
|
||||
else
|
||||
offset = (page * per_page) - pinned_topics.count
|
||||
offset = (page * per_page) - pinned_topics.length
|
||||
offset = 0 unless offset > 0
|
||||
unpinned_topics.offset(offset).to_a
|
||||
end
|
||||
@ -559,7 +557,7 @@ class TopicQuery
|
||||
end
|
||||
elsif @options[:no_tags]
|
||||
# the following will do: ("topics"."id" NOT IN (SELECT DISTINCT "topic_tags"."topic_id" FROM "topic_tags"))
|
||||
result = result.where.not(id: TopicTag.select(:topic_id).uniq)
|
||||
result = result.where.not(id: TopicTag.distinct.pluck(:topic_id))
|
||||
end
|
||||
end
|
||||
|
||||
@ -576,7 +574,6 @@ class TopicQuery
|
||||
end
|
||||
|
||||
result = result.limit(options[:per_page]) unless options[:limit] == false
|
||||
|
||||
result = result.visible if options[:visible]
|
||||
result = result.where.not(topics: { id: options[:except_topic_ids] }).references(:topics) if options[:except_topic_ids]
|
||||
|
||||
|
Reference in New Issue
Block a user