2016-10-12 20:07:57 +03:00
|
|
|
class Conflicts
|
|
|
|
include ActiveModel::Model
|
|
|
|
|
|
|
|
attr_accessor :left, :right
|
|
|
|
|
|
|
|
def conflicts
|
2016-10-12 21:57:30 +03:00
|
|
|
TalkPreference.joins('INNER JOIN "selected_talks" AS "left"
|
2016-10-12 20:07:57 +03:00
|
|
|
ON "left"."talk_preference_id" = "talk_preferences"."unique_id"
|
2016-10-12 21:57:30 +03:00
|
|
|
INNER JOIN "selected_talks" AS "right"
|
2016-10-12 20:07:57 +03:00
|
|
|
ON "right"."talk_preference_id" = "talk_preferences"."unique_id"').where(left: {talk_id: @left}, right: {talk_id: @right}).count
|
|
|
|
end
|
|
|
|
end
|