mirror of
https://github.com/openSUSE/osem.git
synced 2026-08-13 19:54:02 +00:00
Merge pull request #173 from ChrisBr/new_dashboard
Implements event submissions over time chart
This commit is contained in:
commit
fa129de063
12 changed files with 215 additions and 9 deletions
|
|
@ -7,4 +7,20 @@ class CallForPapers < ActiveRecord::Base
|
|||
validates_presence_of :start_date, :end_date, :hard_deadline
|
||||
validates :rating, :numericality => { :greater_than_or_equal_to => 0, :less_than_or_equal_to => 10 }
|
||||
|
||||
def self.max_weeks
|
||||
all = CallForPapers.all
|
||||
result = [0]
|
||||
all.each do |cfp|
|
||||
result.push(cfp.end_week - cfp.start_week)
|
||||
end
|
||||
result.max
|
||||
end
|
||||
|
||||
def start_week
|
||||
start_date.strftime('%W').to_i
|
||||
end
|
||||
|
||||
def end_week
|
||||
end_date.strftime('%W').to_i
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -124,6 +124,43 @@ class Conference < ActiveRecord::Base
|
|||
return false
|
||||
end
|
||||
|
||||
##
|
||||
# Returns an array with the summarized event submissions per week.
|
||||
# ====Params:
|
||||
# * +weeks+ -> Integer with number of weeks. This is necessary to compare conferences.
|
||||
#
|
||||
# ====Returns
|
||||
# * +Array+ -> e.g. [0, 3, 3, 5] -> first week 0 events, second week 3 events.
|
||||
def get_submissions_per_week(weeks)
|
||||
result = []
|
||||
|
||||
if call_for_papers && events
|
||||
submissions = events.select('id, created_at').group_by { |t| t.week }
|
||||
start_week = call_for_papers.start_week
|
||||
sum = 0
|
||||
|
||||
(0..weeks - 1).each do |week|
|
||||
if submissions["#{week + start_week}"]
|
||||
sum += submissions["#{week + start_week}"].length
|
||||
end
|
||||
result.push(sum)
|
||||
end
|
||||
else
|
||||
result = Array.new(weeks, 0)
|
||||
end
|
||||
result
|
||||
end
|
||||
|
||||
##
|
||||
# Checks if the conference is pending.
|
||||
#
|
||||
# ====Returns
|
||||
# * +false+ -> If the conference start date is in the past.
|
||||
# * +true+ -> If the conference start date is in the future.
|
||||
def pending?
|
||||
start_date > Date.today
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
##
|
||||
|
|
|
|||
|
|
@ -174,6 +174,10 @@ class Event < ActiveRecord::Base
|
|||
end
|
||||
end
|
||||
|
||||
def week
|
||||
created_at.strftime('%W')
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def abstract_limit
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue