Fix slow hashtag timelines with any[] when using min_id (#41132)
This commit is contained in:
1 parent
43f1092217
commit
f38ea42abf
2 files changed
+24
No files matched your search
@@ -30,6 +30,7 @@ class TagFeed < PublicFeed
|
||||
scope.merge!(tagged_with_any_scope)
|
||||
scope.merge!(tagged_with_all_scope)
|
||||
scope.merge!(tagged_with_none_scope)
|
||||
scope.merge!(tagged_with_cursor_scope(max_id, since_id, min_id))
|
||||
scope.merge!(local_only_scope) if local_only?
|
||||
scope.merge!(remote_only_scope) if remote_only?
|
||||
scope.merge!(account_filters_scope) if account?
|
||||
@@ -60,6 +61,14 @@ class TagFeed < PublicFeed
|
||||
Status.group(:id).tagged_with_none(tags_for(options[:none]))
|
||||
end
|
||||
|
||||
def tagged_with_cursor_scope(max_id, since_id, min_id)
|
||||
lower_id = min_id.presence || since_id.presence
|
||||
scope = Status.all
|
||||
scope = scope.where(statuses_tags: { status_id: ...max_id }) if max_id.present?
|
||||
scope = scope.where('statuses_tags.status_id > ?', lower_id) if lower_id.present?
|
||||
scope
|
||||
end
|
||||
|
||||
def tags_for(names)
|
||||
Tag.matching_name(Array(names).take(LIMIT_PER_MODE)).pluck(:id) if names.present?
|
||||
end
|
||||
|
||||
@@ -67,6 +67,21 @@ RSpec.describe TagFeed do
|
||||
expect(results).to include(status)
|
||||
end
|
||||
|
||||
it 'paginates with max_id' do
|
||||
results = described_class.new(tag_cats, nil, any: [tag_dogs.name]).get(20, both.id)
|
||||
expect(results).to contain_exactly(status_tagged_with_cats, status_tagged_with_dogs)
|
||||
end
|
||||
|
||||
it 'paginates with since_id' do
|
||||
results = described_class.new(tag_cats, nil, any: [tag_dogs.name]).get(20, nil, status_tagged_with_cats.id)
|
||||
expect(results).to contain_exactly(status_tagged_with_dogs, both)
|
||||
end
|
||||
|
||||
it 'paginates with min_id' do
|
||||
results = described_class.new(tag_cats, nil, any: [tag_dogs.name]).get(20, nil, nil, status_tagged_with_cats.id)
|
||||
expect(results).to contain_exactly(status_tagged_with_dogs, both)
|
||||
end
|
||||
|
||||
context 'when both local_topic_feed_access and remote_topic_feed_access are disabled' do
|
||||
before do
|
||||
Setting.local_topic_feed_access = 'disabled'
|
||||
|
||||
Reference in new issue
Block a user