From c91e0dd15595facae36dd877ec72282a7c4027e8 Mon Sep 17 00:00:00 2001 From: Jeremy Friesen Date: Mon, 19 Sep 2022 20:32:49 -0400 Subject: [PATCH] Ensuring Hyrax::UserStatImporter returns false on exception Prior to this commit, in the retriable block, if we hit an exception, we'd return `true` and upstream we'd raise an exception. In the below code, the `extract_stats_for` is returning true, because calls to `Rails.logger.info` return true. ```ruby view_stats = extract_stats_for(object: file, from: FileViewStat, start_date: start_date, user: user) stats = tally_results(view_stats, :views, stats) if view_stats.present? ``` This resulted in attempting to call `.each` on the `view_stats`; which was true. This builds on a [reported issue in Slack][1]. Closes #5873 [1]:https://samvera.slack.com/archives/C0F9JQJDQ/p1663608069939129 --- app/services/hyrax/user_stat_importer.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/services/hyrax/user_stat_importer.rb b/app/services/hyrax/user_stat_importer.rb index 0b460910d5..cb269cdad0 100644 --- a/app/services/hyrax/user_stat_importer.rb +++ b/app/services/hyrax/user_stat_importer.rb @@ -84,6 +84,8 @@ def rescue_and_retry(fail_message) rescue StandardError => exception log_message fail_message log_message "Last exception #{exception}" + # Without returning false, we return the results of log_message; which is true. + false end def date_since_last_cache(user)