Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,5 @@ vendor/cache
*.csv
.sass-cache
debug.js.coffee

.idea
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ gem 'dalli'
# Debugging
gem 'exception_notification'
group :development do
gem "pry"
gem "pry-rails"
gem 'meta_request'
gem 'rails-erd'
gem 'hirb'
Expand Down
6 changes: 4 additions & 2 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ GEM
debugger-linecache (~> 1.2.0)
debugger-ruby_core_source (~> 1.2.3)
debugger-linecache (1.2.0)
debugger-ruby_core_source (1.2.3)
debugger-ruby_core_source (1.2.4)
diff-lcs (1.2.4)
dropbox-sdk (1.6.2)
json
Expand Down Expand Up @@ -200,6 +200,8 @@ GEM
coderay (~> 1.0.5)
method_source (~> 0.8)
slop (~> 3.4)
pry-rails (0.3.2)
pry (>= 0.9.10)
pundit (0.2.1)
activesupport (>= 3.0.0)
rack (1.5.2)
Expand Down Expand Up @@ -351,7 +353,7 @@ DEPENDENCIES
mini_magick
newrelic_rpm
pg
pry
pry-rails
pundit
rails (= 4.0.2)
rails-erd
Expand Down
Empty file added Readme
Empty file.
102 changes: 102 additions & 0 deletions app/controllers/static_pages_controller.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,106 @@
class StaticPagesController < ApplicationController
def about
end

def reports
end

def coalition_report

@report = {}
# {"IT" => {members: 30, involvement: 30}}

if Rapidfire::Attempt.present?
Rapidfire::Attempt.all.each do |at|

at.answers.find_by(question_id: 5).answer_text.split(',').reject(&:blank?).each do |sector_id|
sector = Sector.find(sector_id.to_i).name
@report[sector] ||= Hash.new(0)
#@report[sector][:involvement] = ((Rapidfire::Answer.where(answer_text: sector_id).count * 100) / Rapidfire::Attempt.count.to_f).round(2)
@report[sector][:involvement] += 1
answer_row = at.answers.find_by(question_id: 6)
members = answer_row.answer_text.to_i
@report[sector][:members] += members
end

end
end

@report[:involvement_total] = @report.each_key.inject(0) { |sum, sector| sum + @report[sector][:involvement] }

end

def activity_summary
@summary = {}

if params[:start_date] and params[:end_date].present?
activities = Rapidfire::Attempt.where("activity_date >= ? AND activity_date <= ?", params[:start_date], params[:end_date])
activities.each do |at|
activity = at.activity_type
@summary[activity] ||= Hash.new(0)
@summary[activity][:period] += 1
@summary[activity][:stop_act] += at.completed_for.include?('Stop ACT') ? 1 : 0
@summary[activity][:drug_free] += at.completed_for.include?('Drug Free Communities') ? 1 : 0
@summary[activity][:participants] += at.answers.find_by(question_id: 6).answer_text.to_i
@summary[activity][:adult] += at.answers.find_by(question_id: 12).answer_text.to_i
@summary[activity][:youth] += at.answers.find_by(question_id: 13).answer_text.to_i
@summary[activity][:very] += at.answers.find_by(question_id: 1).answer_text == 'Very Successful' ? 1 : 0
@summary[activity][:moderate] += at.answers.find_by(question_id: 1).answer_text == 'Moderately Successful' ? 1 : 0
@summary[activity][:not_successful] += at.answers.find_by(question_id: 1).answer_text == 'Not at All Successful' ? 1 : 0
end
else
Rapidfire::Attempt.all.each do |at|
activity = at.activity_type
@summary[activity] ||= Hash.new(0)
@summary[activity][:period] += 1
@summary[activity][:stop_act] += at.completed_for.include?('Stop ACT') ? 1 : 0
@summary[activity][:drug_free] += at.completed_for.include?('Drug Free Communities') ? 1 : 0
@summary[activity][:participants] += at.answers.find_by(question_id: 6).answer_text.to_i
@summary[activity][:adult] += at.answers.find_by(question_id: 12).answer_text.to_i
@summary[activity][:youth] += at.answers.find_by(question_id: 13).answer_text.to_i
@summary[activity][:very] += at.answers.find_by(question_id: 1).answer_text == 'Very Successful' ? 1 : 0
@summary[activity][:moderate] += at.answers.find_by(question_id: 1).answer_text == 'Moderately Successful' ? 1 : 0
@summary[activity][:not_successful] += at.answers.find_by(question_id: 1).answer_text == 'Not at All Successful' ? 1 : 0
end
end
end

def major_matrix_report
@records = {}
if params[:start_date] and params[:end_date].present?
records = Rapidfire::Attempt.where("activity_date >= ? AND activity_date <= ?", params[:start_date], params[:end_date])
records.each do |at|
activity = at.answers.find_by(question_id: 2).answer_text
@records[activity] ||= Hash.new(0)
@records[activity][:count] += 1
end
else
Rapidfire::Attempt.all.each do |at|
activity = at.answers.find_by(question_id: 2).answer_text
@records[activity] ||= Hash.new(0)
@records[activity][:count] += 1
end
end
@activities = Hash[(@records.sort_by { |key, record| record[:count] }).reverse]
end

def strategy_report
@records = {}
if params[:start_date] and params[:end_date].present?
records = Rapidfire::Attempt.where("activity_date >= ? AND activity_date <= ?", params[:start_date], params[:end_date])
records.each do |at|
activity = at.answers.find_by(question_id: 4).answer_text
@records[activity] ||= Hash.new(0)
@records[activity][:count] += 1
end
else
Rapidfire::Attempt.all.each do |at|
activity = at.answers.find_by(question_id: 4).answer_text
@records[activity] ||= Hash.new(0)
@records[activity][:count] += 1
end
end
@activities = Hash[(@records.sort_by { |key, record| record[:count] }).reverse]
end

end
13 changes: 13 additions & 0 deletions app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -85,4 +85,17 @@ def scope_links(scopes, scope_params)
end
links
end

def display_answer_content ans
if ans.question.id == 5
Sector.find(ans.answer_text.to_i).name
else
ans.answer_text.to_i
end
end

def display_in_percent(val, p)
val.nonzero? ? "#{((val * 100) / p.to_f).round(2)} %" : "0%".html_safe
end

end
1 change: 1 addition & 0 deletions app/models/sector.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
class Sector < ActiveRecord::Base
has_many :organizations
has_many :users, through: :organizations
validates_presence_of :name
end
5 changes: 5 additions & 0 deletions app/views/layouts/_menu.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,8 @@
%i.fa.fa-file-text.fa-fw
%span.hidden-sm Documents

%li{class: ('active' if controller.controller_name == 'static_pages' && params[:action] == 'reports')}
= link_to reports_url do
%i.fa.fa-info.fa-fw
%span.hidden-sm Reports

101 changes: 101 additions & 0 deletions app/views/static_pages/activity_summary.html.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
- title "Activity Summary"

= form_tag activity_summary_path, method: :get do
.row
.col-md-12
.form-group
.col-md-10
%table{style: 'width: 100%'}
%tr
%td.c{style: 'width: 15%'}
%strong Search :
%td{style: 'width: 35%'}
= text_field_tag :start_date, '', class: 'form-control', data: { 'date-format' => 'yyyy-mm-dd' }, placeholder: 'Date From'
%td{style: 'width: 35%'}
= text_field_tag :end_date, '', class: 'form-control', data: { 'date-format' => 'yyyy-mm-dd' }, placeholder: 'Date To'
%td.c{style: 'width: 15%'}
= submit_tag('Search', class: 'btn btn-primary')



.row
%br
.col-md-12
%table.table.table-striped.table-condensed
%thead
%tr
%th.c Activity Type
%th.c # in Period
%th.c Completed for
%th.c Total Participants
%th.c Volunteer Hours
%th.c Sectors
%th.c Successfulness
%tbody
%tr
%td.c
%td.c
%td.c
%table
%tr
%th.c % for Stop Act
%th.c % Drug Free Community
%td.c
%td.c
%table{style: 'width: 100%;'}
%tr
%th.c Adults
%th.c Youth
%td.c
%table{style: 'width: 100%;'}
%tr
%th.c{style: 'width: 50%'} Count
%th.c{style: 'width: 50%'} %
%td.c
%table
%tr
%td.c{colspan: 2} Very Successful
%td.c{colspan: 2} Moderately Successful
%td.c{colspan: 2} Not at All Successful
%tr
%th.c #
%th.c %
%th.c #
%th.c %
%th.c #
%th.c %

- @summary.each_key do |activity|
%tr
%td.c= activity
%td.c= @summary[activity][:period]
%td.c
%table{style: 'width: 80%;'}
%tr
%td.c{style: 'width: 50%;'}= display_in_percent @summary[activity][:stop_act], @summary[activity][:period]
%td.c{style: 'width: 50%;'}= display_in_percent @summary[activity][:drug_free], @summary[activity][:period]
%td.c= pluralize(@summary[activity][:participants], 'Person')

%td.c
%table{style: 'width: 100%;'}
%tr
%td.c= @summary[activity][:adult]
%td.c= @summary[activity][:youth]

%td.c
%table{style: 'width: 100%;'}
%tr
%td.c{style: 'width: 50%'} 3
%td.c{style: 'width: 50%'} 60%
%td.c
%table{style: 'width: 100%'}
%tr
%td.c{style: 'width: 15%'}= @summary[activity][:very]
%td.c{style: 'width: 15%'}= display_in_percent @summary[activity][:very], @summary[activity][:period]
%td.c{style: 'width: 17%'}= @summary[activity][:moderate]
%td.c{style: 'width: 17%'}= display_in_percent @summary[activity][:moderate], @summary[activity][:period]
%td.c{style: 'width: 16%'}= @summary[activity][:not_successful]
%td.c{style: 'width: 17%'}= display_in_percent @summary[activity][:not_successful], @summary[activity][:period]



63 changes: 63 additions & 0 deletions app/views/static_pages/coalition_meeting_report.html.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
- title "Coalition Meeting Report"

.row
%br
.col-md-2
%strong Select Date Range
.col-md-4
.form-group
.col-md-2
%label From
.col-md-10
%input(id ='activity_date' class= 'form-control' data-date-format= "yyyy-mm-dd")
.col-md-4
.form-group
.col-md-2
%label To
.col-md-10
%input{id: 'activity_date1', class: 'form-control'}



.row
%br
.col-md-12
%fieldset
%legend Average Attendance
.panel.panel-primary.form-group.question-panel
.panel-heading How many people were involved in the activity?
.panel-body
10 People

%fieldset
%legend Sector Involvement
.panel.panel-primary.form-group.question-panel
.panel-heading What sectors were served by this activity?
.panel-body
.col-md-8
.col-md-2 IT
.col-md-6 - 20%
.col-md-8
.col-md-2 Retail
.col-md-6 - 30%
.col-md-8
.col-md-2 Banking
.col-md-6 - 40%

%fieldset
%legend Coalition Member Attendance
.panel.panel-primary.form-group.question-panel
.panel-heading Were any of the participants members of the coalition?
.panel-body
.col-md-8
80%

%fieldset
%legend Coalition Member Involvement
.panel.panel-primary.form-group.question-panel
.panel-heading Calculation of coalition member attendance to the total attendance in (%).
.panel-body
.col-md-8
.col-md-2 60-70%
.col-md-6 - High

22 changes: 22 additions & 0 deletions app/views/static_pages/coalition_report.html.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
- title "User/Coalition Report"
.row
.col-md-12
%table.table.table-striped.table-condensed
%thead
%tr
%th.c Sector
%th.c # of Members/Users
%th.c # Involvement (%)
%tbody
- @report.each_key do |sector|
- next if sector == :involvement_total
%tr
%td.c= sector
%td.c= @report[sector][:members]
%td.c= "#{display_in_percent(@report[sector][:involvement], @report[:involvement_total])}"






Loading