Class: ExistClient::TimeTracking
- Defined in:
- lib/exist_client/time_tracking.rb,
lib/exist_client/time_tracking/entry.rb
Defined Under Namespace
Classes: Entry
Constant Summary collapse
- PRODUCTIVITY_LABELS =
{ productive: "productive_min", neutral: "neutral_min", distracting: "distracting_min" }
Instance Attribute Summary
Attributes inherited from Reporter
#data_path, #plugin, #report_period
Class Method Summary collapse
Instance Method Summary collapse
Methods inherited from Reporter
Constructor Details
This class inherits a constructor from ExistClient::Reporter
Class Method Details
.setup ⇒ Object
11 12 13 |
# File 'lib/exist_client/time_tracking.rb', line 11 def self.setup Config.data_path_for(self).mkpath end |
Instance Method Details
#report ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/exist_client/time_tracking.rb', line 15 def report ExistClient.log "Reporting time tracking" all_entries = plugin.entries(report_period, data_path).map { |entry_data| Entry.new(entry_data) } grouped_entries = filter_entries(all_entries).group_by(&:logical_date) if grouped_entries.any? ExistClient.log "Found data for the following dates:", indent: 1 ExistClient.log grouped_entries.keys.sort.map { |date| date.strftime("%-m/%-d") }.join(", "), indent: 1 else ExistClient.log "No new data found", indent: 1 return end values = grouped_entries.flat_map do |date, date_entries| build_productivity_values(date, date_entries) end ExistClient.log "Reporting data...", indent: 1 ExistClient.post(values) end |