Class: ExistClient::Tasks
- Defined in:
- lib/exist_client/tasks.rb,
lib/exist_client/tasks/task.rb
Defined Under Namespace
Classes: Task
Instance Attribute Summary
Attributes inherited from Reporter
#data_path, #plugin, #report_period
Instance Method Summary collapse
Methods inherited from Reporter
#initialize, metric_name, setup
Constructor Details
This class inherits a constructor from ExistClient::Reporter
Instance Method Details
#report ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/exist_client/tasks.rb', line 5 def report ExistClient.log "Reporting completed tasks" completed_tasks = plugin.completed_tasks(report_period, data_path).map { |task_data| Task.new(task_data) } grouped_tasks = filter_tasks(completed_tasks).group_by(&:logical_date) if grouped_tasks.any? ExistClient.log "Found data for the following dates:", indent: 1 ExistClient.log grouped_tasks.keys.sort.map { |date| date.strftime("%-m/%-d") }.join(", "), indent: 1 else ExistClient.log "No new data found", indent: 1 return end values = grouped_tasks.map do |date, tasks| { name: "tasks_completed", date: date.to_s, value: tasks.size } end ExistClient.log "Reporting completed tasks data...", indent: 1 ExistClient.post(values) end |