Skip to content

Commit

Permalink
Saving and displaying hoshin health historic data
Browse files Browse the repository at this point in the history
  • Loading branch information
gabriprat committed Dec 31, 2015
1 parent 41c1500 commit ad0de00
Show file tree
Hide file tree
Showing 204 changed files with 679 additions and 310 deletions.
3 changes: 2 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ gem 'pg'

gem 'json'

gem 'sprockets-rails', '~> 2.3.0'
gem 'sass-rails'
gem 'coffee-rails'
gem 'uglifier', '>= 1.3.0'
Expand Down Expand Up @@ -102,7 +103,7 @@ gem 'resque-delay', :git => "git://github.com/rykov/resque-delay.git"
gem 'paranoia'
gem "secure_headers", :require => 'secure_headers'
gem 'papercrop'
gem 'responders', '~> 2.0'
gem 'responders', '= 2.1.0'
gem 'flipper'
gem 'flipper-ui'
gem 'flipper-activerecord'
Expand Down
102 changes: 53 additions & 49 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ GIT

GIT
remote: git://github.com/ericallam/font_assets
revision: ae6671f2aca867a1103bae2fdaaeb91cf71d6639
revision: d0db51614d924c7672406e617475b43df239d620
specs:
font_assets (0.1.12)
font_assets (0.1.13)
rack

GIT
Expand All @@ -31,7 +31,7 @@ GIT

GIT
remote: git://github.com/gabriprat/morrisjs-rails
revision: 7b3fd14fc43e5bb3b6b16a08c20e170075d52575
revision: 74a627c9848f06344752a1e7f0a8b4512ebe89b3
specs:
morrisjs-rails (0.5.1)
railties (> 3.1, < 5)
Expand Down Expand Up @@ -101,7 +101,7 @@ GEM
erubis (~> 2.7.0)
rails-dom-testing (~> 1.0, >= 1.0.5)
rails-html-sanitizer (~> 1.0, >= 1.0.2)
active_record_query_trace (1.5.2)
active_record_query_trace (1.5.3)
activejob (4.2.5)
activesupport (= 4.2.5)
globalid (>= 0.3.0)
Expand All @@ -120,14 +120,14 @@ GEM
tzinfo (~> 1.1)
acts_as_list (0.7.2)
activerecord (>= 3.0)
addressable (2.3.8)
addressable (2.4.0)
amoeba (3.0.0)
activerecord (>= 3.2.6)
ancestry (2.1.0)
activerecord (>= 3.0.0)
ansi (1.5.0)
arel (6.0.3)
autoprefixer-rails (6.1.0.1)
autoprefixer-rails (6.2.3)
execjs
json
aws-sdk-v1 (1.66.0)
Expand All @@ -139,27 +139,29 @@ GEM
bootbox-rails (0.5.0)
bootstrap-datepicker-rails (1.5.0)
railties (>= 3.0)
bootstrap-sass (3.3.5.1)
autoprefixer-rails (>= 5.0.0.1)
sass (>= 3.3.0)
bootstrap-sass (3.3.6)
autoprefixer-rails (>= 5.2.1)
sass (>= 3.3.4)
bootstrap-switch-rails (3.3.3)
builder (3.2.2)
climate_control (0.0.3)
activesupport (>= 3.0)
clockwork (1.2.0)
activesupport
tzinfo
cocaine (0.5.7)
cocaine (0.5.8)
climate_control (>= 0.0.3, < 1.0)
codeclimate-test-reporter (0.4.8)
simplecov (>= 0.7.1, < 1.0.0)
coffee-rails (4.1.0)
coffee-rails (4.1.1)
coffee-script (>= 2.2.0)
railties (>= 4.0.0, < 5.0)
railties (>= 4.0.0, < 5.1.x)
coffee-script (2.4.1)
coffee-script-source
execjs
coffee-script-source (1.10.0)
concurrent-ruby (1.0.0)
concurrent-ruby (1.0.0-java)
css_parser (1.3.7)
addressable
derailed (0.1.0)
Expand All @@ -175,45 +177,45 @@ GEM
detect_timezone_rails (0.0.5)
railties (>= 3.1)
docile (1.1.5)
dryml (2.2.2)
dryml (2.2.4)
actionpack
hobo_support (= 2.2.2)
hobo_support (= 2.2.4)
erubis (2.7.0)
excon (0.45.4)
execjs (2.6.0)
faraday (0.9.2)
multipart-post (>= 1.2, < 3)
flipper (0.7.1)
flipper (0.7.3)
flipper-activerecord (0.1.1)
activerecord (>= 4.2.0.beta2)
flipper (~> 0.6)
flipper-ui (0.7.1)
flipper-ui (0.7.3)
erubis (~> 2.7.0)
flipper (~> 0.7.1)
flipper (~> 0.7.3)
rack (~> 1.4, < 1.7)
rack-protection (~> 1.5.3)
get_process_mem (0.2.0)
globalid (0.3.6)
activesupport (>= 4.1.0)
hashie (3.4.3)
heapy (0.1.1)
hobo (2.2.2)
dryml (= 2.2.2)
hobo_fields (= 2.2.2)
hobo_support (= 2.2.2)
heapy (0.1.2)
hobo (2.2.4)
dryml (= 2.2.4)
hobo_fields (= 2.2.4)
hobo_support (= 2.2.4)
hobo_will_paginate
hobo_fields (2.2.2)
hobo_support (= 2.2.2)
hobo_jquery (2.2.2)
hobo_rapid (= 2.2.2)
hobo_fields (2.2.4)
hobo_support (= 2.2.4)
hobo_jquery (2.2.4)
hobo_rapid (= 2.2.4)
jquery-rails (~> 2.0)
hobo_jquery_ui (2.2.2)
hobo (= 2.2.2)
hobo_jquery (= 2.2.2)
hobo_jquery_ui (2.2.4)
hobo (= 2.2.4)
hobo_jquery (= 2.2.4)
jquery-ui-themes (~> 0.0.4)
hobo_rapid (2.2.2)
hobo (= 2.2.2)
hobo_support (2.2.2)
hobo_rapid (2.2.4)
hobo (= 2.2.4)
hobo_support (2.2.4)
rails (~> 4.2.4)
hobo_will_paginate (2.1.1)
hobo_will_paginate-bootstrap (1.0.0)
Expand All @@ -224,7 +226,7 @@ GEM
json (~> 1.8)
multi_xml (>= 0.5.2)
i18n (0.7.0)
immigrant (0.3.4)
immigrant (0.3.5)
activerecord (>= 3.0)
jquery-cookie-rails (1.3.1.1)
railties (>= 3.2.0, < 5.0)
Expand All @@ -244,9 +246,9 @@ GEM
mime-types (>= 1.16, < 3)
memory_profiler (0.9.6)
metaclass (0.0.4)
mime-types (2.6.2)
mime-types (2.99)
mimemagic (0.3.0)
mini_portile (0.6.2)
mini_portile2 (2.0.0)
minitest (5.8.3)
mixpanel-ruby (2.2.0)
mocha (1.1.0)
Expand All @@ -261,19 +263,19 @@ GEM
murmurhash3 (0.1.6-java)
nested_has_many_through (0.0.2)
rails (>= 3.0.0)
newrelic_rpm (3.14.0.305)
nokogiri (1.6.6.3)
mini_portile (~> 0.6.0)
nokogiri (1.6.6.3-java)
newrelic_rpm (3.14.1.311)
nokogiri (1.6.7.1)
mini_portile2 (~> 2.0.0.rc2)
nokogiri (1.6.7.1-java)
oauth2 (1.0.0)
faraday (>= 0.8, < 0.10)
jwt (~> 1.0)
multi_json (~> 1.3)
multi_xml (~> 0.5)
rack (~> 1.2)
omniauth (1.2.2)
omniauth (1.3.1)
hashie (>= 1.2, < 4)
rack (~> 1.0)
rack (>= 1.0, < 3)
omniauth-google-oauth2 (0.2.10)
addressable (~> 2.3)
jwt (~> 1.0)
Expand Down Expand Up @@ -301,7 +303,7 @@ GEM
rails (>= 3.1)
paranoia (2.1.4)
activerecord (~> 4.0)
paypal-sdk-rest (1.3.4)
paypal-sdk-rest (1.4.1)
multi_json (~> 1.0)
uuidtools (~> 2.1)
xml-simple
Expand Down Expand Up @@ -400,15 +402,15 @@ GEM
ruby-saml (1.0.0)
nokogiri (>= 1.5.10)
uuid (~> 2.3)
rufus-scheduler (3.1.10)
sass (3.4.19)
rufus-scheduler (3.2.0)
sass (3.4.20)
sass-rails (5.0.4)
railties (>= 4.0.0, < 5.0)
sass (~> 3.1)
sprockets (>= 2.8, < 4.0)
sprockets-rails (>= 2.0, < 4.0)
tilt (>= 1.1, < 3)
secure_headers (2.4.3)
secure_headers (2.4.4)
user_agent_parser
simplecov (0.11.1)
docile (~> 1.1.0)
Expand All @@ -419,7 +421,8 @@ GEM
rack (~> 1.4)
rack-protection (~> 1.4)
tilt (>= 1.3, < 3)
sprockets (3.4.0)
sprockets (3.5.2)
concurrent-ruby (~> 1.0)
rack (> 1, < 3)
sprockets-rails (2.3.3)
actionpack (>= 3.0)
Expand All @@ -445,9 +448,9 @@ GEM
uuidtools (2.1.5)
vegas (0.1.11)
rack (>= 1.0.0)
webshims-rails (1.15.9)
webshims-rails (1.15.10)
rails (> 3.1.0)
wicked_pdf (1.0.0)
wicked_pdf (1.0.3)
xml-simple (1.1.5)
yui-compressor (0.12.0)

Expand Down Expand Up @@ -522,13 +525,14 @@ DEPENDENCIES
redis-rails
redis-store
request_store
responders (~> 2.0)
responders (= 2.1.0)
resque
resque-delay!
ruby-hmac
ruby-openid
sass-rails
secure_headers
sprockets-rails (~> 2.3.0)
turn
uglifier (>= 1.3.0)
unscoped_associations
Expand Down
10 changes: 9 additions & 1 deletion app/assets/javascripts/application/global.js
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,14 @@ var ylabelformat = function(val, i) {
}
return ret;
}

var ylabelformatHealth = function(val, i) {
var ret = val;
var that = $(document);
if (ret == null) return ret;
ret = numberFormat((ret.toFixed(2) * 1).toString()) + '%';
return ret;
}
$(document).ready(function() {
$("#sso-login").submit(function () {
var val = $("#sso-login input[name=email]").val();
Expand Down Expand Up @@ -561,5 +569,5 @@ $(document).ready(function() {
numeral.language(document.documentElement.lang);
});

$.webshims.setOptions('basePath', '/webshims/1.15.9/shims/');
$.webshims.setOptions('basePath', '/webshims/1.15.10/shims/');
$.webshims.polyfill("forms");
40 changes: 40 additions & 0 deletions app/models/health_history.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
class HealthHistory < ActiveRecord::Base

hobo_model # Don't put anything above this

fields do
day :date
objectives_health :decimal
indicators_health :decimal
tasks_health :decimal
timestamps
end
index [:hoshin_id, :day], :unique => true

attr_accessible :day, :objectives_health, :indicators_health, :tasks_health

belongs_to :hoshin, :inverse_of => :health_histories, :counter_cache => false, :null => false
belongs_to :company, :null => false

before_create do |hh|
hh.company = hh.hoshin.company
end
# --- Permissions --- #

def create_permitted?
same_company
end

def update_permitted?
hoshin.updatable_by?(acting_user)
end

def destroy_permitted?
hoshin.destroyable_by?(acting_user)
end

def view_permitted?(field)
self.new_record? || hoshin.viewable_by?(acting_user)
end

end
15 changes: 15 additions & 0 deletions app/models/hoshin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ class Hoshin < ActiveRecord::Base
has_many :tasks, -> { readonly }, :through => :objectives, :accessible => true
has_many :goals, -> { order :position }, :dependent => :destroy, :inverse_of => :hoshin
has_many :log, :class_name => "HoshinLog", :inverse_of => :hoshin
has_many :health_histories, -> { order :day }, :dependent => :destroy, :inverse_of => :hoshin


children :areas

Expand Down Expand Up @@ -142,6 +144,19 @@ def clone_available
user.save!
end

after_save do |obj|
if obj.health_updated_at_changed? || true
#one data point per day
hh = HealthHistory.unscoped.where(:day => obj.health_updated_at, :hoshin_id => obj.id).first_or_initialize
hh.hoshin = obj
hh.day = obj.health_updated_at
hh.objectives_health = obj.objectives_health
hh.indicators_health = obj.indicators_health
hh.tasks_health = obj.tasks_health
hh.save!
end
end

def company_name=(name)
@company_name = name
end
Expand Down
Loading

0 comments on commit ad0de00

Please sign in to comment.