Introduce a ConflictsForTalk model and db view
This commit is contained in:
parent
42582f79b3
commit
b9e6a89f22
|
@ -0,0 +1,2 @@
|
|||
class ConflictsForTalk < ApplicationRecord
|
||||
end
|
|
@ -0,0 +1,19 @@
|
|||
CONFLICTS_FOR_TALK_VIEW_SQL = <<EOS
|
||||
CREATE VIEW "conflicts_for_talks" AS
|
||||
SELECT DISTINCT("left"."talk_id") AS "talk_id",
|
||||
COUNT("right"."talk_preference_id") - 1 AS "conflicts"
|
||||
FROM "selected_talks" AS "left"
|
||||
INNER JOIN "selected_talks" AS "right"
|
||||
ON "left"."talk_id" = "right"."talk_id"
|
||||
GROUP BY "left"."id";
|
||||
EOS
|
||||
|
||||
class AddConflictsForTalkView < ActiveRecord::Migration[5.0]
|
||||
def up
|
||||
execute CONFLICTS_FOR_TALK_VIEW_SQL
|
||||
end
|
||||
|
||||
def down
|
||||
execute 'DROP VIEW "conflicts_for_talks"'
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue