mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-27 17:46:05 -05:00
PERF: only rebuild entire top topic table daily
This commit is contained in:
parent
cceed615a3
commit
e4909c017c
2 changed files with 19 additions and 2 deletions
19
app/jobs/scheduled/daily.rb
Normal file
19
app/jobs/scheduled/daily.rb
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
require_dependency 'score_calculator'
|
||||||
|
|
||||||
|
module Jobs
|
||||||
|
|
||||||
|
# This job will run on a regular basis to update statistics and denormalized data.
|
||||||
|
# If it does not run, the site will not function properly.
|
||||||
|
class PeriodicalUpdates < Jobs::Scheduled
|
||||||
|
every 1.day
|
||||||
|
|
||||||
|
def execute(args)
|
||||||
|
# TODO: optimise this against a big site before doing this any more
|
||||||
|
# frequently
|
||||||
|
#
|
||||||
|
# current implementation wipes an entire table and rebuilds causing huge
|
||||||
|
# amounts of IO
|
||||||
|
TopTopic.refresh!
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -21,8 +21,6 @@ module Jobs
|
||||||
# Update the scores of posts
|
# Update the scores of posts
|
||||||
ScoreCalculator.new.calculate
|
ScoreCalculator.new.calculate
|
||||||
|
|
||||||
# Refresh Top Topics
|
|
||||||
TopTopic.refresh!
|
|
||||||
|
|
||||||
# Automatically close stuff that we missed
|
# Automatically close stuff that we missed
|
||||||
Topic.auto_close
|
Topic.auto_close
|
||||||
|
|
Loading…
Reference in a new issue