Skip to content

Instantly share code, notes, and snippets.

@braidn
Created February 12, 2014 16:26
Show Gist options
  • Save braidn/8959034 to your computer and use it in GitHub Desktop.
Save braidn/8959034 to your computer and use it in GitHub Desktop.
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
@braidn
Copy link
Author

braidn commented Feb 12, 2014

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment