Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save halan/5938576 to your computer and use it in GitHub Desktop.
Save halan/5938576 to your computer and use it in GitHub Desktop.
require 'delegate'
class AbandonedTrialQuery < SimpleDelegator
def initialize(relation = Account.scoped)
super(relation.where(plan: nil, invites_count: 0))
end
end
old_accounts = Account.where("created_at < ?", 1.month.ago)
old_abandoned_trials = AbandonedTrialQuery.new(old_accounts)
old_abandoned_trials.find_each do |account|
account.send_offer_for_support
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment