Skip to content

Commit

Permalink
Continue sending if errors
Browse files Browse the repository at this point in the history
+ add cleanup rake
  • Loading branch information
parterburn committed Nov 3, 2024
1 parent 49fbf72 commit cef985a
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion lib/tasks/entry.rake
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@ namespace :entry do
Sentry.set_user(id: user.id, email: user.email)
Sentry.set_tags(plan: user.plan)
Sentry.capture_exception(error, extra: { sent_in_hour: sent_in_hour })
next # continue with the next user
end
end

Expand All @@ -226,7 +227,19 @@ namespace :entry do

# Clean up empty entries
Entry.where("(image IS null OR image = '') AND (body IS null OR body = '')").each(&:destroy)

# Turn off emails for users with low entries and no activity for 2 years
users_with_no_activity = User.joins(:entries)
.group('users.id')
.having('COUNT(entries.id) < 5')
.having('MAX(entries.created_at) < ?', 2.years.ago)
.where.not(frequency: [])

users_with_no_activity.each do |user|
user.previous_frequency = user.frequency
user.frequency = []
user.save
end
end
end

end

0 comments on commit cef985a

Please sign in to comment.