about summary refs log tree commit diff stats
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/mailers/vote_mailer.rb7
-rw-r--r--app/models/quote.rb4
-rw-r--r--app/views/vote_mailer/daily_report_email.html.haml8
-rw-r--r--app/views/vote_mailer/daily_report_email.text.erb5
4 files changed, 24 insertions, 0 deletions
diff --git a/app/mailers/vote_mailer.rb b/app/mailers/vote_mailer.rb new file mode 100644 index 0000000..77ac3d1 --- /dev/null +++ b/app/mailers/vote_mailer.rb
@@ -0,0 +1,7 @@
1class VoteMailer < ApplicationMailer
2 def daily_report_email
3 @entries = params[:votes].group_by { |v| "#{v.votable_type}_#{v.votable_id}" }.values
4 # weird way of getting the admin's email
5 mail to: User.first.email, subject: "[Four Island] You have upvotes!"
6 end
7end
diff --git a/app/models/quote.rb b/app/models/quote.rb index 518d53b..3301667 100644 --- a/app/models/quote.rb +++ b/app/models/quote.rb
@@ -17,6 +17,10 @@ class Quote < ApplicationRecord
17 scope :published, -> { where(state: :published) } 17 scope :published, -> { where(state: :published) }
18 scope :pending, -> { where(state: :pending) } 18 scope :pending, -> { where(state: :pending) }
19 19
20 def title
21 "Quote \##{id}"
22 end
23
20 def published_date 24 def published_date
21 created_at.strftime("%B %d %Y at %I:%M:%S") + created_at.strftime(" %p").downcase + created_at.strftime(" %Z") 25 created_at.strftime("%B %d %Y at %I:%M:%S") + created_at.strftime(" %p").downcase + created_at.strftime(" %Z")
22 end 26 end
diff --git a/app/views/vote_mailer/daily_report_email.html.haml b/app/views/vote_mailer/daily_report_email.html.haml new file mode 100644 index 0000000..ab54df2 --- /dev/null +++ b/app/views/vote_mailer/daily_report_email.html.haml
@@ -0,0 +1,8 @@
1%p
2 Users have upvoted content on Four Island in the last day!
3%ul
4 - @entries.each do |entry|
5 %li
6 %strong= pluralize(entry.size, "person")
7 left an upvote on
8 = link_to entry.first.votable.title, entry.first.votable, style: "font-weight: bold; font-style: italic"
diff --git a/app/views/vote_mailer/daily_report_email.text.erb b/app/views/vote_mailer/daily_report_email.text.erb new file mode 100644 index 0000000..22ea368 --- /dev/null +++ b/app/views/vote_mailer/daily_report_email.text.erb
@@ -0,0 +1,5 @@
1Users have upvoted content on Four Island in the last day!
2
3<% @entries.each do |entry| %>
4- <%= pluralize(entry.size, "person") %> left an upvote on <%= entry.first.votable.title %> (<%= url_for(entry.first.votable) %>)
5<% end %>