Skip to content
This repository has been archived by the owner on Nov 13, 2019. It is now read-only.

Commit

Permalink
Improve time reporting
Browse files Browse the repository at this point in the history
Overrides the Rails distance_of_time_in_words with the dotiw gem. This gives us the ability to report exact time diffs in words accumulating on the type we want. So two days of compute renders as 48 hours. 3600 seconds renders as 1 hour instead of about 1 hour. Due to the imprecision in our set up we are not reporting on seconds. dotiw provides backwards compatible functionality using the :vague keyword if we need that elsewhere in the application.
  • Loading branch information
Morgan Rodgers committed Dec 7, 2018
1 parent 0a2d8c0 commit ee1a02f
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
3 changes: 2 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ gem 'rails_12factor', group: :production
gem 'mocha', '~> 1.1', group: :test
gem "spring", group: :test
gem 'autoprefixer-rails', '~> 8.4'
gem 'dotiw'

# OOD specific gems
gem 'ood_support', '~> 0.0.2'
Expand All @@ -68,4 +69,4 @@ gem 'pbs', '~> 2.2.1'

# Security updates
gem "rack", ">= 1.6.11"
gem "loofah", ">= 2.2.2", "~> 2.2"
gem "loofah", ">= 2.2.2", "~> 2.2"
4 changes: 4 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ GEM
dotenv-rails (2.5.0)
dotenv (= 2.5.0)
railties (>= 3.2, < 6.0)
dotiw (4.0.1)
actionpack (>= 4)
i18n
erubis (2.7.0)
execjs (2.7.0)
ffi (1.9.25)
Expand Down Expand Up @@ -199,6 +202,7 @@ DEPENDENCIES
coffee-rails (~> 4.1.0)
data-confirm-modal (~> 1.2)
dotenv-rails (~> 2.0)
dotiw
font-awesome-sass (= 5.0.9)
jbuilder (~> 2.0)
jquery-datatables-rails (~> 3.4)
Expand Down
6 changes: 3 additions & 3 deletions app/helpers/batch_connect/sessions_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,17 +65,17 @@ def time(session)
if time_limit && time_used
concat content_tag(:strong, "Time Remaining:")
concat " "
concat distance_of_time_in_words(time_limit - time_used)
concat distance_of_time_in_words(time_limit - time_used, 0, false, :only => [:minutes, :hours], :accumulate_on => :hours)
elsif time_used
concat content_tag(:strong, "Time Used:")
concat " "
concat distance_of_time_in_words(time_used)
concat distance_of_time_in_words(time_used, 0, false, :only => [:minutes, :hours], :accumulate_on => :hours)
end
else # not starting or running
if time_limit
concat content_tag(:strong, "Time Requested:")
concat " "
concat pluralize(time_limit / 3600, "hour")
concat distance_of_time_in_words(time_limit, 0, false, :only => [:minutes, :hours], :accumulate_on => :hours)
end
end
end
Expand Down

0 comments on commit ee1a02f

Please sign in to comment.