A platform for community discussion. Free, open, simple.
FIX: Correct the date range in d-rewind (#39805)
Jarek Radosz7b1c9cc3dc96
diff --git a/plugins/discourse-rewind/app/services/discourse_rewind/fetch_report.rb b/plugins/discourse-rewind/app/services/discourse_rewind/fetch_report.rbindex 0361f25acc5..de47a106eeb 100644--- a/plugins/discourse-rewind/app/services/discourse_rewind/fetch_report.rb+++ b/plugins/discourse-rewind/app/services/discourse_rewind/fetch_report.rb@@ -39,7 +39,7 @@ module DiscourseRewindprivatedef fetch_date(params:, year:)- Date.new(year).all_year+ Time.zone.local(year).all_yearenddef fetch_report(params:, for_user:, year:, date:)diff --git a/plugins/discourse-rewind/app/services/discourse_rewind/fetch_reports.rb b/plugins/discourse-rewind/app/services/discourse_rewind/fetch_reports.rbindex bba3e1d1a70..204d91baf80 100644--- a/plugins/discourse-rewind/app/services/discourse_rewind/fetch_reports.rb+++ b/plugins/discourse-rewind/app/services/discourse_rewind/fetch_reports.rb@@ -57,7 +57,7 @@ module DiscourseRewindprivatedef fetch_date(params:, year:)- Date.new(year).all_year+ Time.zone.local(year).all_yearenddef fetch_reports(date:, for_user:, year:)diff --git a/plugins/discourse-rewind/plugin.rb b/plugins/discourse-rewind/plugin.rbindex cce16924dd4..abe95539940 100644--- a/plugins/discourse-rewind/plugin.rb+++ b/plugins/discourse-rewind/plugin.rb@@ -28,16 +28,6 @@ module ::DiscourseRewinddate ||= Time.zone.nowdate.month == 1 ? date.year - 1 : date.yearend-- def self.year_date_range(date_override = nil)- current_date = date_override.presence || Time.zone.now-- # Outside December/January, only available in development- is_rewind_period = current_date.month == 1 || current_date.month == 12- return false if !is_rewind_period && !Rails.env.development?-- Date.new(current_date.year).all_year- endendrequire_relative "lib/discourse_rewind/engine"diff --git a/plugins/discourse-rewind/spec/plugin_helper.rb b/plugins/discourse-rewind/spec/plugin_helper.rbindex 8eb52988233..5eed95bb838 100644--- a/plugins/discourse-rewind/spec/plugin_helper.rb+++ b/plugins/discourse-rewind/spec/plugin_helper.rb@@ -7,8 +7,7 @@ module DiscourseRewindSpecHelperenddef random_datetime- # date should be defined via fab! in the spec- date.to_a.sample.to_datetime + rand(0..23).hours + rand(0..59).minutes + rand(0..59).seconds+ rand(date.first.to_time...date.last.to_time)endend