Move the confirmation date to Proposition
This commit is contained in:
parent
eeb7f4ef61
commit
8c94bb3a87
|
@ -5,6 +5,7 @@ module Proposable
|
|||
has_one :proposition, as: :proposable, dependent: :destroy
|
||||
has_one :proposer, through: :proposition
|
||||
delegate :email, to: :proposer, prefix: true
|
||||
scope :confirmed, -> { joins(:proposition).where.not(propositions: {confirmed_at: nil}) }
|
||||
|
||||
Proposition.defined_enums["status"].keys.each do |status|
|
||||
scope status.to_sym, -> { joins(:proposition).where(propositions: {status: Proposition.defined_enums["status"][status]}) }
|
||||
|
|
|
@ -32,7 +32,7 @@ class Conference < ActiveRecord::Base
|
|||
end
|
||||
|
||||
def submissions_grouped_by_confirmation_day
|
||||
submissions = events.approved.confirmed.group('date(events.confirmed_at)').select('date(events.confirmed_at) as confirmed_at, count(events.id) as number')
|
||||
submissions = events.approved.confirmed.group('date(propositions.confirmed_at)').select('date(propositions.confirmed_at) as confirmed_at, count(events.id) as number')
|
||||
submissions.group_by { |s| s.confirmed_at.to_date }
|
||||
end
|
||||
|
||||
|
|
|
@ -24,8 +24,6 @@ class Event < ActiveRecord::Base
|
|||
validates :length, presence: true, numericality: {only_integer: true}
|
||||
validate :length_is_within_the_permitted_interval
|
||||
|
||||
scope :confirmed, -> { where.not confirmed_at: nil }
|
||||
|
||||
delegate :status, to: :proposition
|
||||
|
||||
def proposer_profile
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
class AddConfirmedAtToPropositions < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :propositions, :confirmed_at, :timestamp
|
||||
end
|
||||
end
|
|
@ -0,0 +1,17 @@
|
|||
class Event < ActiveRecord::Base
|
||||
include Proposable
|
||||
end
|
||||
|
||||
class PopulateConfirmedAtOfPropositionsForEvents < ActiveRecord::Migration
|
||||
def up
|
||||
Event.all do |event|
|
||||
event.proposition.update(confirmed_at: event.confirmed_at)
|
||||
end
|
||||
end
|
||||
|
||||
def down
|
||||
Event.all do |event|
|
||||
event.update(confirmed_at: event.proposition.confirmed_at)
|
||||
end
|
||||
end
|
||||
end
|
|
@ -0,0 +1,5 @@
|
|||
class RemoveConfirmedAtFromEvents < ActiveRecord::Migration
|
||||
def change
|
||||
remove_column :events, :confirmed_at, :timestamp
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue