Class: WatchTower::Server::File

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
lib/watch_tower/server/models/file.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.date_range(from, to) ⇒ ActiveRelation

Return an ActiveRelation limited to a date range

Parameters:

  • From (String)

    date

  • To (String)

    date

Returns:

  • (ActiveRelation)


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_timeInteger

Returns the sum of all elapsed time

Returns:

  • (Integer)


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

#percentObject

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