mirror of
https://github.com/codeninjasllc/discourse.git
synced 2025-02-17 04:01:29 -05:00
Merge pull request #4055 from tgxworld/fix_topic_view_not_working_in_redis_readonly
FIX: Topic view not working when Redis is readonly.
This commit is contained in:
commit
9d24a00f2e
2 changed files with 13 additions and 1 deletions
|
@ -47,7 +47,12 @@ class RandomTopicSelector
|
|||
$redis.ltrim(key, count, -1)
|
||||
end
|
||||
|
||||
results = results[0]
|
||||
if !results.is_a?(Array) # Redis is in readonly mode
|
||||
results = $redis.lrange(key, 0, count-1)
|
||||
else
|
||||
results = results[0]
|
||||
end
|
||||
|
||||
results.map!(&:to_i)
|
||||
|
||||
left = count - results.length
|
||||
|
|
|
@ -11,8 +11,15 @@ describe RandomTopicSelector do
|
|||
$redis.rpush key, t
|
||||
end
|
||||
|
||||
expect(RandomTopicSelector.next(0)).to eq([])
|
||||
expect(RandomTopicSelector.next(2)).to eq([0,1])
|
||||
|
||||
$redis.expects(:multi).returns(Discourse.received_readonly!)
|
||||
expect(RandomTopicSelector.next(2)).to eq([2,3])
|
||||
$redis.unstub(:multi)
|
||||
|
||||
expect(RandomTopicSelector.next(2)).to eq([2,3])
|
||||
expect(RandomTopicSelector.next(2)).to eq([])
|
||||
end
|
||||
|
||||
it 'can correctly backfill' do
|
||||
|
|
Loading…
Reference in a new issue