-
-
Save dyatlov/6fcf619bad1ff08f1ebc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def self.unanswered_with_max(user, task) | |
joins("LEFT OUTER JOIN answers a ON a.input_id=inputs.id \ | |
AND a.user_id=#{user.id}") | |
.joins('LEFT OUTER JOIN input_allocations ON input_allocations.input_id='\ | |
'inputs.id AND input_allocations.expires_at>\'' + Time.now.to_s + '\'') | |
.where('a.id IS NULL') | |
.where(task_id: task.id) | |
.group('inputs.id,input_allocations.input_id') | |
.having('COUNT(input_allocations.input_id)+answers_count<?', | |
task.max_answers) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment