Optimize number of conflicts calculation
This commit is contained in:
parent
c3ba666730
commit
c8b9d96f66
|
@ -19,9 +19,11 @@ class ConflictCoefficient
|
||||||
end
|
end
|
||||||
|
|
||||||
def conflicts
|
def conflicts
|
||||||
@conflicts ||= talk_preferences.select do |talk_preference|
|
talk_preferences.joins('INNER JOIN "selected_talks" AS left
|
||||||
talk_preference.include_all? [@left, @right]
|
ON "left"."talk_preference_id" = "talk_preferences"."unique_id"
|
||||||
end.count
|
INNER JOIN "selected_talks" AS right
|
||||||
|
ON "right"."talk_preference_id" = "talk_preferences"."unique_id"')
|
||||||
|
.where(left: {talk_id: @left}, right: {talk_id: @right}).count
|
||||||
end
|
end
|
||||||
|
|
||||||
def total_votes
|
def total_votes
|
||||||
|
|
Loading…
Reference in New Issue