[Bugfix] Conference methods related to weeks now database independent
This commit is contained in:
parent
fd95570c02
commit
596027e49b
6 changed files with 55 additions and 4 deletions
|
|
@ -179,7 +179,7 @@ class Conference < ActiveRecord::Base
|
|||
result = []
|
||||
|
||||
if call_for_papers && events
|
||||
submissions = events.group("strftime('%W', created_at)").count
|
||||
submissions = events.group(:week).count
|
||||
start_week = call_for_papers.start_week
|
||||
weeks = call_for_papers.weeks
|
||||
result = calculate_items_per_week(start_week, weeks, submissions)
|
||||
|
|
@ -196,7 +196,7 @@ class Conference < ActiveRecord::Base
|
|||
result = []
|
||||
|
||||
if call_for_papers && events
|
||||
submissions = events.where('state = ?', state).group("strftime('%W', created_at)").count
|
||||
submissions = events.where('state = ?', state).group(:week).count
|
||||
start_week = call_for_papers.start_week
|
||||
weeks = call_for_papers.weeks
|
||||
result = calculate_items_per_week(start_week, weeks, submissions)
|
||||
|
|
@ -216,7 +216,7 @@ class Conference < ActiveRecord::Base
|
|||
registration_start_date &&
|
||||
registration_end_date
|
||||
|
||||
reg = registrations.group("strftime('%W', created_at)").count
|
||||
reg = registrations.group(:week).count
|
||||
start_week = get_registration_start_week
|
||||
weeks = registration_weeks
|
||||
result = calculate_items_per_week(start_week, weeks, reg)
|
||||
|
|
|
|||
|
|
@ -5,6 +5,8 @@ class Event < ActiveRecord::Base
|
|||
|
||||
acts_as_commentable
|
||||
|
||||
after_create :set_week
|
||||
|
||||
has_many :event_people, :dependent => :destroy
|
||||
has_many :event_attachments, :dependent => :destroy
|
||||
has_many :people, :through => :event_people
|
||||
|
|
@ -203,4 +205,8 @@ class Event < ActiveRecord::Base
|
|||
self.guid = guid
|
||||
end
|
||||
|
||||
def set_week
|
||||
self.week = created_at.strftime('%W')
|
||||
save!
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -34,7 +34,16 @@ class Registration < ActiveRecord::Base
|
|||
|
||||
alias_attribute :other_needs, :other_special_needs
|
||||
|
||||
after_create :set_week
|
||||
|
||||
def week
|
||||
created_at.strftime('%W').to_i
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def set_week
|
||||
self.week = created_at.strftime('%W')
|
||||
save!
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue