A platform for community discussion. Free, open, simple.
DEV: Publish DiscourseEvent after top topic period is calculated (#29142)
Mark VanLandingham909264ee759d
diff --git a/app/models/top_topic.rb b/app/models/top_topic.rbindex 31fbf4efd5c..6b0c7c9050b 100644--- a/app/models/top_topic.rb+++ b/app/models/top_topic.rb@@ -212,6 +212,8 @@ class TopTopic < ActiveRecord::BaseSQLDB.exec(sql, from: start_of(period))++ DiscourseEvent.trigger(:top_score_computed, period: period)enddef self.start_of(period)diff --git a/spec/models/top_topic_spec.rb b/spec/models/top_topic_spec.rbindex 0286d2faa60..0906b9a7db8 100644--- a/spec/models/top_topic_spec.rb+++ b/spec/models/top_topic_spec.rb@@ -152,5 +152,12 @@ RSpec.describe TopTopic do0.0000000001,).of(10.602059991328)end++ it "triggers a DiscourseEvent for each refreshed period" do+ events = DiscourseEvent.track_events(:top_score_computed) { TopTopic.refresh! }+ periods = events.map { |e| e[:params].first[:period] }++ expect(periods).to match_array(%i[daily weekly monthly quarterly yearly all])+ endendend