0
0
Fork 0

Fix trends returning less results per page when filtered in REST API (#17996)

- Change filtering and pagination to occur in SQL instead of Redis
- Change rank/score displayed on trends in admin UI to be locale-specific
This commit is contained in:
Eugen Rochko 2022-04-08 17:10:53 +02:00 committed by GitHub
parent 6b72641641
commit fd9a9b07c2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 20 additions and 31 deletions

View file

@ -37,12 +37,12 @@ class Trends::Base
Trends::Query.new(key_prefix, klass)
end
def score(id)
redis.zscore("#{key_prefix}:all", id) || 0
def score(id, locale: nil)
redis.zscore([key_prefix, 'all', locale].compact.join(':'), id) || 0
end
def rank(id)
redis.zrevrank("#{key_prefix}:allowed", id)
def rank(id, locale: nil)
redis.zrevrank([key_prefix, 'allowed', locale].compact.join(':'), id)
end
def currently_trending_ids(allowed, limit)