mirror of
https://github.com/discourse/discourse.git
synced 2024-11-24 01:58:12 +08:00
PERF: move avg time calculation to daily
This commit is contained in:
parent
6e9f5f5584
commit
95d13bf68a
15
app/jobs/scheduled/calculate_avg_time.rb
Normal file
15
app/jobs/scheduled/calculate_avg_time.rb
Normal file
|
@ -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
|
|
@ -8,9 +8,6 @@ module Jobs
|
||||||
every 15.minutes
|
every 15.minutes
|
||||||
|
|
||||||
def execute(args)
|
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
|
# Feature topics in categories
|
||||||
CategoryFeaturedTopic.feature_topics
|
CategoryFeaturedTopic.feature_topics
|
||||||
|
|
Loading…
Reference in New Issue
Block a user