Skip to content

Commit

Permalink
Adds presenter and method to the batch_update_logging #1005
Browse files Browse the repository at this point in the history
  • Loading branch information
mauditecandela authored and ragesoss committed Dec 13, 2017
1 parent 9e83049 commit 272233b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
15 changes: 15 additions & 0 deletions app/presenters/metrics_updates.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
class MetricsUpdates

def self.metrics
Setting.find_or_create_by(key: 'metrics_update').value
end

def self.update_metrics(key, time)
setting = Setting.find_or_create_by(key: 'metrics_update')
metric = setting.value
metric[key] = time
setting.value = metric
setting.save
end

end
2 changes: 1 addition & 1 deletion lib/data_cycle/batch_update_logging.rb
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def log_end_of_update(message)
log_message 'Update finished'
total_time = distance_of_time_in_words(@start_time, @end_time)
Rails.logger.info "#{message} Time: #{total_time}."
UpdateLog.log_update(@end_time.to_datetime) if self.class.to_s == 'ConstantUpdate'
MetricsUpdates.update_metrics(@end_time, total_time)
Raven.capture_message message,
level: 'info',
tags: { update_time: total_time },
Expand Down

0 comments on commit 272233b

Please sign in to comment.