Files
grecia/config/schedule.rb
Javi Martín a5646fcdb3 Remove Cron job to generate stats
Since now generating stats (assuming the results aren't in the cache)
only takes a few seconds even when there are a hundred thousand
participants, as opposed to the several minutes it took to generate them
when we introduced the Cron job, we can simply generate the stats during
the first request to the stats page.

Note that, in order to avoid creating a temporary table when the stats
are cached, we're making sure we only create this table when we need to.
Otherwise, we could spend up to 1 second on every request to the stats
page creating a table that isn't going to be used.

Also note we're using an instance variable to check whether we're
creating a table; I tried to use `table_exists?`, but it didn't work. I
wonder whether `table_exists?` doesn't detect temporary tables.
2024-05-17 16:08:08 +02:00

42 lines
978 B
Ruby

# Use this file to easily define all of your cron jobs.
#
# It's helpful, but not entirely necessary to understand cron before proceeding.
# http://en.wikipedia.org/wiki/Cron
# Example:
#
# set :output, "/path/to/my/cron_log.log"
#
# every 2.hours do
# command "/usr/bin/some_great_command"
# runner "MyModel.some_method"
# rake "some:great:rake:task"
# end
#
# every 4.days do
# runner "AnotherModel.prune_old_records"
# end
# Learn more: http://github.com/javan/whenever
every 1.minute do
command "date > ~/cron-test.txt"
end
every 1.day, at: "5:00 am" do
rake "-s sitemap:refresh:no_ping"
end
every 1.day, at: "1:00 am", roles: [:cron] do
rake "files:remove_old_cached_attachments"
end
every 1.day, at: "3:00 am", roles: [:cron] do
rake "votes:reset_hot_score"
end
every :reboot do
# Number of workers must be kept in sync with capistrano's delayed_job_workers
command "cd #{@path} && RAILS_ENV=#{@environment} bin/delayed_job -m -n 2 restart"
end