Created
February 12, 2014 16:26
-
-
Save braidn/8959034 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
module Quarterly | |
class CancelationsReport | |
class CancelationsPresenter < SimpleDelegator | |
def subscription_totals(start) | |
subscriptions.active.where("created_at < ?", start).count | |
end | |
def new_subscriptions(start, ending) | |
subscriptions.active.where("created_at between ? and ?", | |
start, ending).count | |
end | |
def subscription_cancelations(start, ending) | |
subscriptions.where("canceled_at between ? and ?", | |
start, ending).count | |
end | |
def net_subscriptions(start, ending) | |
new_subscriptions(start, ending) - | |
subscription_cancelations(start, ending) | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
We care about "Active Subscriptions" so our net would be poluted with the odd canceled_at subscriptions. Our net total over the lifetime of the sub would be subs_total + new?