Class: WatchTower::Server::File
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- WatchTower::Server::File
- Defined in:
- lib/watch_tower/server/models/file.rb
Class Method Summary collapse
-
.date_range(from, to) ⇒ ActiveRelation
Return an ActiveRelation limited to a date range.
-
.sum_elapsed_time ⇒ Integer
Returns the sum of all elapsed time.
Instance Method Summary collapse
-
#percent ⇒ Object
Return the percent of this file.
Class Method Details
.date_range(from, to) ⇒ ActiveRelation
Return an ActiveRelation limited to a date range
30 31 32 33 34 35 36 37 38 |
# File 'lib/watch_tower/server/models/file.rb', line 30 def self.date_range(from, to) from = Date.strptime(from, '%m/%d/%Y') to = Date.strptime(to, '%m/%d/%Y') joins(:durations => :file). where('durations.date >= ?', from). where('durations.date <= ?', to). select('DISTINCT files.*') end |
.sum_elapsed_time ⇒ Integer
Returns the sum of all elapsed time
43 44 45 |
# File 'lib/watch_tower/server/models/file.rb', line 43 def self.sum_elapsed_time sum(:elapsed_time) end |
Instance Method Details
#percent ⇒ Object
Return the percent of this file
21 22 23 |
# File 'lib/watch_tower/server/models/file.rb', line 21 def percent (elapsed_time * 100) / project.files.sum_elapsed_time end |