Skip to content

Instantly share code, notes, and snippets.

@bogdan
Created June 5, 2015 14:20
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/34c7bad08b842f38d975 to your computer and use it in GitHub Desktop.
Save bogdan/34c7bad08b842f38d975 to your computer and use it in GitHub Desktop.
diff --git a/app/models/campaign.rb b/app/models/campaign.rb
index f1b12a5..7d54830 100644
--- a/app/models/campaign.rb
+++ b/app/models/campaign.rb
@@ -687,10 +687,13 @@ class Campaign < BaseModel
end
def expires_at_for_share
+ # If new share needs to be created in expired campaign
+ # we prepare only set it relatively to the campaign deactivation
+ start_time = active? ? Time.now : expires_at
[
# Rounded up to an hour, to reduce count of short_urls
# and make share detection easier
- offer_duration.present? ? (DateTime.now + offer_duration.hours).end_of_hour : nil,
+ offer_duration.present? ? (start_time + offer_duration.hours).end_of_hour : nil,
friend_deadline,
].compact.min.try(:in_time_zone)
end
@@ -858,18 +861,18 @@ protected
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment