From: Aidan Cornelius-Bell Date: Fri, 22 Nov 2024 22:40:12 +0000 (+1030) Subject: Bookmarks now include posts for a weekly summary, uses date sorting like the home... X-Git-Url: https://gitweb.mndrdr.org/?a=commitdiff_plain;h=e9125c8d1658895cb45385630c87f82abc8a8935;p=arelpe.git Bookmarks now include posts for a weekly summary, uses date sorting like the home page, might migrate to this over 'every dispatch as a post' not sure yet. --- diff --git a/app/jobs/weekly_bookmarks_digest_job.rb b/app/jobs/weekly_bookmarks_digest_job.rb index 87e7f74..b38746f 100644 --- a/app/jobs/weekly_bookmarks_digest_job.rb +++ b/app/jobs/weekly_bookmarks_digest_job.rb @@ -4,7 +4,7 @@ class WeeklyBookmarksDigestJob < ApplicationJob def perform(user = nil) start_date = 1.week.ago.beginning_of_week end_date = Time.current.end_of_week - bookmarks = Post.bookmarks.where(created_at: start_date..end_date) + bookmarks = Post.where(created_at: start_date..end_date) # or do User.find_each do |user| for everyone, but that'll break fastmail if user.present? DigestMailer.weekly_bookmarks_digest(user, bookmarks).deliver_now diff --git a/app/mailers/digest_mailer.rb b/app/mailers/digest_mailer.rb index 92e1ab0..803c44d 100644 --- a/app/mailers/digest_mailer.rb +++ b/app/mailers/digest_mailer.rb @@ -7,6 +7,6 @@ class DigestMailer < ApplicationMailer def weekly_bookmarks_digest(user, bookmarks) @user = user @bookmarks = bookmarks - mail(to: @user.email, subject: 'mind reader :: weekly bookmarks digest') + mail(to: @user.email, subject: 'mind reader :: weekly digest') end end diff --git a/app/views/digest_mailer/weekly_bookmarks_digest.html.erb b/app/views/digest_mailer/weekly_bookmarks_digest.html.erb index 03fc0ba..ace210c 100644 --- a/app/views/digest_mailer/weekly_bookmarks_digest.html.erb +++ b/app/views/digest_mailer/weekly_bookmarks_digest.html.erb @@ -1,19 +1,28 @@ -

Your weekly bookmarks digest

+

Dear <%= @user.first_name %>,

-

Hello <%= @user.first_name %>,

+

Here's what's new from mind reader this week:

-

Here are the bookmarks added this week:

+<% @bookmarks.group_by { |bookmark| bookmark.created_at.to_date }.each do |date, bookmarks| %> +

On <%= date.strftime('%B %e, %Y') %>:

- + +<% end %>

Have a great weekend,
-Aidan.

\ No newline at end of file +Aidan.