Created
June 9, 2017 13:09
-
-
Save bogdan/43bbda70214732a39c6d5387f4fe0396 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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