Guest User

Untitled

a guest
Feb 21st, 2018
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. class Site < ActiveRecord::Base
  2. belongs_to :group
  3. belongs_to :status_sensor
  4. has_many :site_options
  5. has_many :status_changes
  6.  
  7. def total_wet_time
  8. @site = site.find(params[:id])
  9. wet_time = 0
  10. for item in @site.status_changes |item|
  11. if KeyWord.get_in_wet_list(item.before) # checks is status==wet
  12. wet_time += item.duration # in seconds
  13. end
  14. end
  15. if KeyWord.get_in_wet_list(@site.sensor.last_value)
  16. wet_time += time_since(@site.sensor.last_page)
  17. end
  18. end
Add Comment
Please, Sign In to add comment