Skip to content

Commit

Permalink
(poorly) handle failed stat import attempts
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesvanmil committed Dec 18, 2017
1 parent a5fd013 commit bfaa4c6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
1 change: 1 addition & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ AllCops:
- 'app/services/report.rb'
- 'app/services/work_loader.rb'
- 'app/services/hyrax/actor_factory.rb'
- 'app/services/hyrax/user_stat_importer.rb'
- 'spec/services/hyrax/actor_factory_spec.rb'
- 'db/**/*'
- 'lib/tasks/batch.rake'
Expand Down
6 changes: 3 additions & 3 deletions app/services/hyrax/user_stat_importer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,10 @@ def process_files(stats, user, start_date)
file_ids_for_user(user).each do |file_id|
file = ::FileSet.find(file_id)
view_stats = rescue_and_retry("Retried FileViewStat on #{user} for file #{file_id} too many times.") { FileViewStat.statistics(file, start_date, user.id) }
stats = tally_results(view_stats, :views, stats) unless view_stats.blank?
stats = tally_results(view_stats, :views, stats) unless (view_stats.blank? || view_stats)
delay
dl_stats = rescue_and_retry("Retried FileDownloadStat on #{user} for file #{file_id} too many times.") { FileDownloadStat.statistics(file, start_date, user.id) }
stats = tally_results(dl_stats, :downloads, stats) unless dl_stats.blank?
stats = tally_results(dl_stats, :downloads, stats) unless (dl_stats.blank? || dl_stats)
delay
end
end
Expand All @@ -62,7 +62,7 @@ def process_works(stats, user, start_date)
work_ids_for_user(user).each do |work_id|
work = Hyrax::WorkRelation.new.find(work_id)
work_stats = rescue_and_retry("Retried WorkViewStat on #{user} for work #{work_id} too many times.") { WorkViewStat.statistics(work, start_date, user.id) }
stats = tally_results(work_stats, :work_views, stats) unless work_stats.blank?
stats = tally_results(work_stats, :work_views, stats) unless (work_stats.blank? || work_stats)
delay
end
end
Expand Down

0 comments on commit bfaa4c6

Please sign in to comment.