From 886173e6faef2c807f578ee9acc22947cb145091 Mon Sep 17 00:00:00 2001 From: Paul Arterburn Date: Tue, 28 May 2024 21:12:30 -0600 Subject: [PATCH] Store code for fixing send issues in rake task --- lib/tasks/entry.rake | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/lib/tasks/entry.rake b/lib/tasks/entry.rake index 6e5be82a..514f2823 100644 --- a/lib/tasks/entry.rake +++ b/lib/tasks/entry.rake @@ -1,6 +1,20 @@ namespace :entry do require 'csv' + # TRIGGERED MANUALLY + # heroku run bundle exec rake "entry:resend_daily_pro_users[2024-01-01]" --app dabble-me --size=standard-1x + task :resend_daily_pro_users, [:send_date] => :environment do |t, args| + send_day = Date.parse(args[:send_date] || Time.current.in_time_zone("America/Denver").to_date.to_s) + users = User.daily_emails.pro_only.subscribed_to_emails.not_just_signed_up.select { |user| user.last_sent_at.before?(24.hours.ago) } + random_inspiration = Inspiration.random + + users.each do |user| + EntryMailer.send_entry(user, random_inspiration, send_day: send_day).deliver_now + send_time = DateTime.parse("#{send_day} #{user.send_time}") + user.update_columns(last_sent_at: send_time) + end + end + # TRIGGERED MANUALLY # rake entry:send_entries_test task :send_entries_test => :environment do