forked from nbgallery/nbgallery
-
Notifications
You must be signed in to change notification settings - Fork 0
/
jobs.rb
46 lines (40 loc) · 1.16 KB
/
jobs.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# Hello world at startup
self.in '1s' do
ScheduledJobs.run(:hello)
end
# Age off
cron GalleryConfig.cron.age_off do
ScheduledJobs.run(:age_off)
end
# Notebook daily summaries
cron GalleryConfig.cron.notebook_dailies do
ScheduledJobs.run(:notebook_dailies)
end
# User click summaries
cron GalleryConfig.cron.user_summaries do
ScheduledJobs.run(:user_summaries)
end
# Notebook click summaries
cron GalleryConfig.cron.notebook_summaries do
ScheduledJobs.run(:notebook_summaries)
end
# Subscription email
cron GalleryConfig.cron.daily_subscription_email do
ScheduledJobs.run(:daily_subscription_email)
end
# Notebook suggestions
if Rails.env.production?
cron GalleryConfig.cron.nightly_computation do
ScheduledJobs.run(:nightly_computation)
end
else
# Run in dev if results are old
latest_recommendation = SuggestedNotebook.maximum(:updated_at) || Time.current
latest_notebook = Notebook.maximum(:updated_at) || Time.current
recommendations_old = SuggestedNotebook.count.zero? || latest_recommendation < latest_notebook
if Notebook.count.nonzero? && recommendations_old
self.in '5m' do
ScheduledJobs.run(:nightly_computation)
end
end
end