Skip to content

Commit 2760038

Browse files
authored
Merge pull request #1216 from DaanVanVugt/feature/stale_events_in_curation_mail
add stale events in curation mail
2 parents 452613e + bd29987 commit 2760038

3 files changed

Lines changed: 58 additions & 5 deletions

File tree

app/mailers/curation_mailer.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ def events_require_approval(provider, cut_off_time)
2929
return unless @provider.content_curation_email.present?
3030

3131
# @events = @provider.events.where { |e| e.lmm_processed > cut_off_time }
32-
@events = @provider.events.filter { |e| e.created_at > cut_off_time }
32+
@new_events = @provider.events.filter { |e| e.created_at > cut_off_time }
33+
@stale_events = @provider.events.filter { |e| e.stale? }
3334
subject = t('mailer.events_require_approval.subject')
3435
mail(subject:, to: @provider.content_curation_email) do |format|
3536
format.html

app/views/curation_mailer/events_require_approval.html.erb

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,19 @@
11
<p>
22
You are receiving this automated email because you are a curator of <%= @provider.title %> on <%= TeSS::Config.site['title_short'] %>.
33
</p>
4-
<% if @events.count.positive? %>
4+
5+
<p>
6+
<strong>New events:</strong>
7+
</p>
8+
9+
<% if @new_events.count.positive? %>
510
<p>
611
If any of these events are incorrect or should not be shown, please follow the link to change them.<br/>
712
If an event should not be shown, disable it on the edit page instead of deleting it to prevent rescraping.<br/>
813
If an event needs changes, lock the changed fields to prevent your changes from being overwritten by the scraper.<br/>
914
</p>
1015

11-
<% @events.each do |event| %>
16+
<% @new_events.each do |event| %>
1217
<p>
1318
<%= link_to event.title, event %><br/>
1419
<strong>description:</strong> <%= event.description %><br/>
@@ -24,3 +29,31 @@
2429
There were no new events this week.
2530
</p>
2631
<% end %>
32+
33+
<p>
34+
<strong>Stale events:</strong>
35+
</p>
36+
37+
<% if @stale_events.count.positive? %>
38+
<p>
39+
These events have not been updated/found by the <%= TeSS::Config.site['title_short'] %> recently.<br/>
40+
If all events for <%= @provider.title %> are stale, the source might have changed, breaking the <%= TeSS::Config.site['title_short'] %> scraper.<br/>
41+
If another duplicate of this event was made, maybe the address to the event page was changed.<br/>
42+
</p>
43+
44+
<% @stale_events.each do |event| %>
45+
<p>
46+
<%= link_to event.title, event %><br/>
47+
<strong>description:</strong> <%= event.description %><br/>
48+
<strong>start:</strong> <%= event.start %><br/>
49+
<strong>end:</strong> <%= event.end %><br/>
50+
<strong>venue:</strong> <%= event.venue %><br/>
51+
<strong>show:</strong> <%= event.visible %><br/>
52+
</p>
53+
54+
<% end %>
55+
<% else %>
56+
<p>
57+
There were no stale events this week.
58+
</p>
59+
<% end %>

app/views/curation_mailer/events_require_approval.text.erb

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
You are receiving this automated email because you are a curator of <%= @provider.title %> on <%= TeSS::Config.site['title_short'] %>.
2-
<% if @events.count.positive? %>
2+
3+
New events:
4+
<% if @new_events.count.positive? %>
35
If any of these events are incorrect or should not be shown, please follow the link to change them.
46
If an event should not be shown, disable it on the edit page instead of deleting it to prevent rescraping.
57
If an event needs changes, lock the changed fields to prevent your changes from being overwritten by the scraper.
68

7-
<% @events.each do |event| %>
9+
<% @new_events.each do |event| %>
810
<%= event.title %> (<%= url_for(event) %>)
911
description: <%= event.description %>
1012
start: <%= event.start %>
@@ -17,4 +19,21 @@ You are receiving this automated email because you are a curator of <%= @provide
1719
There were no new events this week.
1820
<% end %>
1921

22+
Stale events:
23+
<% if @stale_events.count.positive? %>
24+
These events have not been updated/found by the <%= TeSS::Config.site['title_short'] %> recently.<br/>
25+
If all events for <%= @provider.title %> are stale, the source might have changed, breaking the <%= TeSS::Config.site['title_short'] %> scraper.<br/>
26+
If another duplicate of this event was made, maybe the address to the event page was changed.<br/>
2027

28+
<% @stale_events.each do |event| %>
29+
<%= event.title %> (<%= url_for(event) %>)
30+
description: <%= event.description %>
31+
start: <%= event.start %>
32+
end: <%= event.end %>
33+
venue: <%= event.venue %>
34+
show: <%= event.visible %>
35+
36+
<% end %>
37+
<% else %>
38+
There were no stale events this week.
39+
<% end %>

0 commit comments

Comments
 (0)