Skip to content

Commit ceaf2e6

Browse files
committed
Merge pull request code-dot-org#5431 from code-dot-org/hocSignupsDashboard
Creates a dashboard page at /admin/temp/hoc_signups showing HOC 2015 signups.
2 parents 881668e + dadcd7d commit ceaf2e6

File tree

4 files changed

+52
-1
lines changed

4 files changed

+52
-1
lines changed

dashboard/app/controllers/admin_reports_controller.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,16 @@ def all_usage
202202
render 'reports/usage', formats: [:html]
203203
end
204204

205+
def hoc_signups
206+
# Requested by Roxanne on 16 November 2015 to track HOC 2015 signups by day.
207+
authorize! :read, :reports
208+
209+
# Get the HOC 2015 signup counts by day, deduped by email and name.
210+
# TODO(asher): Is this clumsy notation really necessary? Is Sequel really this stupid?
211+
signups_by_day = DB[:forms].where(kind: 'HocSignup2015').group(:name, :email).group_and_count(Sequel.as(Sequel.qualify(:forms, :created_at).cast(:date),:created_at_day)).all.map{|row| [row[:created_at_day].to_s, row[:count].to_i]}
212+
render locals: {signups_by_day: signups_by_day}
213+
end
214+
205215
# Use callbacks to share common setup or constraints between actions.
206216
def set_script
207217
@script = Script.get_from_cache(params[:script_id]) if params[:script_id]
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
- content_for :head do
2+
%script{src:'https://www.google.com/jsapi'}
3+
4+
%h1
5+
Hour of Code 2015 Signups
6+
7+
.by_day
8+
#chart_by_day
9+
%table
10+
%tr
11+
%th Day
12+
%th Count
13+
- signups_by_day.each do |day|
14+
%tr
15+
%td
16+
%span= day[0]
17+
%td
18+
%span= day[1]
19+
20+
- content_for :body_scripts do
21+
:javascript
22+
// Load the Visualization API and the appropriate packages, setting a callback
23+
// to run when the API is loaded.
24+
google.load('visualization', '1.0', {'packages':['corechart']});
25+
google.setOnLoadCallback(drawChart);
26+
var signups_by_day = #{signups_by_day.try(:to_json)}
27+
// The callback that creates and populates the data table, instantiates the
28+
// chart, and draws it.
29+
function drawChart() {
30+
var data = new google.visualization.DataTable();
31+
data.addColumn('string', 'Date');
32+
data.addColumn('number', 'Count');
33+
data.addRows(signups_by_day);
34+
35+
// Instantiate and draw our chart, passing in some options.
36+
var options = {'title': 'HOC 2015 Signups By Day', 'width':400, 'height':300};
37+
var chart = new google.visualization.LineChart(document.getElementById('chart_by_day'));
38+
chart.draw(data, options);
39+
}

dashboard/config/routes.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,8 @@ def redirect_to_teacher_dashboard
178178
post '/milestone/:user_id/:script_level_id', :to => 'activities#milestone', :as => 'milestone'
179179

180180
# one-off internal reports
181-
get '/admin/brook/csppd', to: 'reports#csp_pd_responses', as: 'csp_pd_responses'
181+
get '/admin/temp/csppd', to: 'reports#csp_pd_responses', as: 'csp_pd_responses'
182+
get '/admin/temp/hoc_signups', to: 'admin_reports#hoc_signups', as: 'hoc_signups'
182183

183184
# internal report dashboards
184185
get '/admin/concepts', to: 'admin_reports#admin_concepts', as: 'admin_concepts'

dashboard/test/controllers/admin_reports_controller_test.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ class AdminReportsControllerTest < ActionController::TestCase
3030
generate_admin_only_tests_for :admin_stats
3131
generate_admin_only_tests_for :funometer
3232
# TODO(asher): Add :funometer_by_script and :funometer_by_script_level after fixing routing.
33+
# TODO(asher): Add :hoc_signups after fixing the pegasus-test DB issue.
3334

3435
test 'should get admin progress page' do
3536
get :admin_progress

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy