Skip to content

Instantly share code, notes, and snippets.

@MeenakshiNaik
Created October 7, 2016 06:50
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 MeenakshiNaik/641d580102713e60abd4333b4b3456fa to your computer and use it in GitHub Desktop.
Save MeenakshiNaik/641d580102713e60abd4333b4b3456fa to your computer and use it in GitHub Desktop.
#TEMP FILE
# ISSUED
def self.total_qty_initial(account)
Offer.where(account_id: account.id, active: true, offer_status: ['live', 'ended']).sum(:qty_initial)
end
# NEW USERS
def self.total_new_users(account)
offers = Offer.where(account_id: account.id)
offer_ids = offers.pluck(:id) if offers.present?
OfferUser.where(signup_offer: true, offer_id: offer_ids).count if offer_ids.present?
end
# REDEEMED
def self.total_offer_redeemed(account)
offers = Offer.where(account_id: account.id)
offer_ids = offers.pluck(:id)
OfferUser.where(redeemed: true, offer_id: offer_ids).count if offer_ids.present?
end
# QTY_ACTIVATED
def self.total_qty_activated_offer(account)
Offer.where(account_id: account.id, active: true).sum(:qty_activated)
end
# SCHEDULED
def self.total_qty_initial_scheduled(account)
Offer.where(account_id: account.id, active: true, offer_status: 'scheduled').sum(:qty_initial)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment