Commit 17a3fde5782359ff9b0b4b1a7d105b9339286075
1 parent
fd2f2448
Exists in
master
and in
1 other branch
prompt_ids function is too slow, using improved picker
Showing
1 changed file
with
2 additions
and
1 deletions
Show diff stats
app/models/question.rb
... | ... | @@ -33,8 +33,9 @@ class Question < ActiveRecord::Base |
33 | 33 | end |
34 | 34 | |
35 | 35 | def picked_prompt_id |
36 | + pc = self.prompts_count < 1 ? 2 : self.prompts_count | |
36 | 37 | begin |
37 | - return i = prompt_ids.rand | |
38 | + return rand(pc-1) + prompts.first.id | |
38 | 39 | end until prompts.find(i).active? |
39 | 40 | end |
40 | 41 | ... | ... |