Method: PostRunner::FitFileStore#weekly_report
- Defined in:
- lib/postrunner/FitFileStore.rb
#weekly_report(day) ⇒ Object
394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 |
# File 'lib/postrunner/FitFileStore.rb', line 394 def weekly_report(day) # 'day' specifies the current week. It must be in the form of # YYYY-MM-DD and references a day in the specific week. But we don't # know what timezone the watch was set to for a given date. The files # are always named after the moment of finishing the recording expressed # as GMT time. Each file contains information about the time zone for # the specific file. Recording is always flipped to a new file at # midnight GMT but there are usually multiple files per # GMT day. day_as_time = Time.parse(day).gmtime start_day = day_as_time - (24 * 60 * 60 * (day_as_time.wday - @store['config']['week_start_day'])) # To get weekly intensity minutes we need 7 days of data prior to the # current month start and 1 after to include the following night. We add # at least 12 extra hours to accomondate time zone changes. monitoring_files = monitorings(start_day - 8 * 24 * 60 * 60, start_day + 8 * 24 * 60 * 60) puts MonitoringStatistics.new(monitoring_files).weekly(start_day) end |