Skip to content

Commit

Permalink
Store code for fixing send issues in rake task
Browse files Browse the repository at this point in the history
  • Loading branch information
parterburn committed May 29, 2024
1 parent 9c9a3c6 commit 886173e
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions lib/tasks/entry.rake
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit 886173e

Please sign in to comment.