Skip to content

Instantly share code, notes, and snippets.

@bogdan
Created June 9, 2017 13:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bogdan/43bbda70214732a39c6d5387f4fe0396 to your computer and use it in GitHub Desktop.
Save bogdan/43bbda70214732a39c6d5387f4fe0396 to your computer and use it in GitHub Desktop.
def void!
self.update_attribute(:status, BASE_STATUSES[:voided])
# TODO: Need to better figure out which redeem activity to modify...
# For now, see if there was one around the time of the reward creation and void that if found
[:redeem, :referral].each do |r|
void_activities = offer.activities.by_action(r).by_date_times(created_at..(created_at + 5.minutes))
unless void_activities.empty?
activity = void_activities.first
logger.info("Reward#void! reward #{id} voided, voiding #{activity.action} activity: #{activity.id}")
activity.update_attribute(:action, "#{r}_voided")
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment