Add submissions chart to conferences
This commit is contained in:
parent
d1f49a4218
commit
49079b635e
2
Gemfile
2
Gemfile
|
@ -47,6 +47,8 @@ gem 'font-awesome-rails'
|
||||||
|
|
||||||
gem 'nested_form'
|
gem 'nested_form'
|
||||||
gem 'jquery-datatables-rails'
|
gem 'jquery-datatables-rails'
|
||||||
|
gem 'morrisjs-rails'
|
||||||
|
gem 'raphael-rails'
|
||||||
|
|
||||||
group :development do
|
group :development do
|
||||||
gem 'spring'
|
gem 'spring'
|
||||||
|
|
|
@ -149,6 +149,8 @@ GEM
|
||||||
mime-types (2.4.1)
|
mime-types (2.4.1)
|
||||||
mini_portile (0.6.0)
|
mini_portile (0.6.0)
|
||||||
minitest (5.4.2)
|
minitest (5.4.2)
|
||||||
|
morrisjs-rails (0.5.1)
|
||||||
|
railties (> 3.1, < 5)
|
||||||
multi_json (1.10.1)
|
multi_json (1.10.1)
|
||||||
nested_form (0.3.2)
|
nested_form (0.3.2)
|
||||||
net-scp (1.2.1)
|
net-scp (1.2.1)
|
||||||
|
@ -196,6 +198,7 @@ GEM
|
||||||
rake (>= 0.8.7)
|
rake (>= 0.8.7)
|
||||||
thor (>= 0.18.1, < 2.0)
|
thor (>= 0.18.1, < 2.0)
|
||||||
rake (10.3.2)
|
rake (10.3.2)
|
||||||
|
raphael-rails (2.1.2)
|
||||||
rb-fsevent (0.9.4)
|
rb-fsevent (0.9.4)
|
||||||
rb-inotify (0.9.5)
|
rb-inotify (0.9.5)
|
||||||
ffi (>= 0.5.0)
|
ffi (>= 0.5.0)
|
||||||
|
@ -301,6 +304,7 @@ DEPENDENCIES
|
||||||
guard-rspec
|
guard-rspec
|
||||||
jquery-datatables-rails
|
jquery-datatables-rails
|
||||||
jquery-rails
|
jquery-rails
|
||||||
|
morrisjs-rails
|
||||||
nested_form
|
nested_form
|
||||||
pg
|
pg
|
||||||
phony_rails
|
phony_rails
|
||||||
|
@ -308,6 +312,7 @@ DEPENDENCIES
|
||||||
rails (= 4.1.6)
|
rails (= 4.1.6)
|
||||||
rails-erd
|
rails-erd
|
||||||
rails-i18n
|
rails-i18n
|
||||||
|
raphael-rails
|
||||||
rmagick
|
rmagick
|
||||||
rspec-rails
|
rspec-rails
|
||||||
sass-rails (~> 4.0.3)
|
sass-rails (~> 4.0.3)
|
||||||
|
|
|
@ -5,4 +5,6 @@
|
||||||
//= require dataTables/bootstrap/3/jquery.dataTables.bootstrap
|
//= require dataTables/bootstrap/3/jquery.dataTables.bootstrap
|
||||||
//= require bootstrap-sprockets
|
//= require bootstrap-sprockets
|
||||||
//= require metisMenu/metisMenu
|
//= require metisMenu/metisMenu
|
||||||
|
//= require raphael
|
||||||
|
//= require morris
|
||||||
//= require_directory .
|
//= require_directory .
|
||||||
|
|
|
@ -0,0 +1,9 @@
|
||||||
|
$ ->
|
||||||
|
Morris.Line
|
||||||
|
element: 'submissions-chart'
|
||||||
|
data: $('#submissions-chart').data('submissions')
|
||||||
|
xkey: 'created_at'
|
||||||
|
ykeys: ['all_submissions', 'all_confirmations']
|
||||||
|
labels: ['Submissions', 'Confirmed submissions']
|
||||||
|
lineColors: ['#D9230F', '#469408']
|
||||||
|
resize: true
|
|
@ -7,6 +7,7 @@
|
||||||
@import "metisMenu/metisMenu";
|
@import "metisMenu/metisMenu";
|
||||||
@import "dataTables/jquery.dataTables";
|
@import "dataTables/jquery.dataTables";
|
||||||
@import "dataTables/bootstrap/3/jquery.dataTables.bootstrap";
|
@import "dataTables/bootstrap/3/jquery.dataTables.bootstrap";
|
||||||
|
@import "morris";
|
||||||
|
|
||||||
@import "layout";
|
@import "layout";
|
||||||
@import "navigation";
|
@import "navigation";
|
||||||
|
|
|
@ -0,0 +1,31 @@
|
||||||
|
module ConferencesHelper
|
||||||
|
def submissions_chart_data(conference)
|
||||||
|
submissions_by_day = conference.submissions_grouped_by_day
|
||||||
|
confirmed_by_day = conference.submissions_grouped_by_confirmation_day
|
||||||
|
start_date = conference.created_at.to_date
|
||||||
|
end_date = Time.zone.now.to_date < conference.start_date.to_date ? Time.zone.now.to_date : conference.start_date.to_date
|
||||||
|
|
||||||
|
chart_data = (start_date..end_date).map do |date|
|
||||||
|
{
|
||||||
|
created_at: date,
|
||||||
|
new_submissions: submissions_by_day[date].try(:first).try(:number) || 0,
|
||||||
|
new_confirmations: confirmed_by_day[date].try(:first).try(:number) || 0
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
chart_data.each_with_index do |entry, index|
|
||||||
|
entry[:all_submissions] = if index == 0
|
||||||
|
entry[:new_submissions]
|
||||||
|
else
|
||||||
|
chart_data[index - 1][:all_submissions] + entry[:new_submissions]
|
||||||
|
end
|
||||||
|
|
||||||
|
entry[:all_confirmations] = if index == 0
|
||||||
|
entry[:new_confirmations]
|
||||||
|
else
|
||||||
|
chart_data[index - 1][:all_confirmations] + entry[:new_confirmations]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
chart_data
|
||||||
|
end
|
||||||
|
end
|
|
@ -23,6 +23,20 @@ class Conference < ActiveRecord::Base
|
||||||
future.first || last
|
future.first || last
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def submissions_grouped_by_day
|
||||||
|
submissions = Event.where(track: tracks, created_at: created_at..start_date)
|
||||||
|
submissions = submissions.group('date(created_at)')
|
||||||
|
submissions = submissions.select('created_at, count(id) as number')
|
||||||
|
submissions.group_by { |s| s.created_at.to_date }
|
||||||
|
end
|
||||||
|
|
||||||
|
def submissions_grouped_by_confirmation_day
|
||||||
|
submissions = Event.approved.where(track: tracks, created_at: created_at..start_date).where.not(confirmed_at: nil)
|
||||||
|
submissions = submissions.group('date(confirmed_at)')
|
||||||
|
submissions = submissions.select('confirmed_at, count(id) as number')
|
||||||
|
submissions.group_by { |s| s.confirmed_at.to_date }
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def close_all_other_calls_for_papers
|
def close_all_other_calls_for_papers
|
||||||
|
|
|
@ -69,3 +69,6 @@
|
||||||
span.pull-left = t 'views.conference.see_details'
|
span.pull-left = t 'views.conference.see_details'
|
||||||
span.pull-right = fa_icon 'arrow-circle-right'
|
span.pull-right = fa_icon 'arrow-circle-right'
|
||||||
span.clearfix
|
span.clearfix
|
||||||
|
.row
|
||||||
|
.col-lg-12
|
||||||
|
.submissions-chart#submissions-chart data-submissions="#{submissions_chart_data(@conference).to_json}"
|
||||||
|
|
Loading…
Reference in New Issue