diff --git a/app/jobs/scheduled/calculate_avg_time.rb b/app/jobs/scheduled/calculate_avg_time.rb new file mode 100644 index 00000000000..e842285ab4a --- /dev/null +++ b/app/jobs/scheduled/calculate_avg_time.rb @@ -0,0 +1,15 @@ +module Jobs + + class CalculateAvgTime < Jobs::Scheduled + every 1.day + + # PERF: these calculations can become exceedingly expnsive + # they run a huge gemoetric mean and are hard to optimise + # defer to only run once a day + def execute(args) + # Update the average times + Post.calculate_avg_time(2.days.ago) + Topic.calculate_avg_time(2.days.ago) + end + end +end diff --git a/app/jobs/scheduled/periodical_updates.rb b/app/jobs/scheduled/periodical_updates.rb index 27aaac4d433..2266ca17f2e 100644 --- a/app/jobs/scheduled/periodical_updates.rb +++ b/app/jobs/scheduled/periodical_updates.rb @@ -8,9 +8,6 @@ module Jobs every 15.minutes def execute(args) - # Update the average times - Post.calculate_avg_time(1.day.ago) - Topic.calculate_avg_time(1.day.ago) # Feature topics in categories CategoryFeaturedTopic.feature_topics