Skip to content

Instantly share code, notes, and snippets.

@radar
Last active June 26, 2017 06:05
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 radar/1e5ec86a594a9a1ad1b8baf0c606870c to your computer and use it in GitHub Desktop.
Save radar/1e5ec86a594a9a1ad1b8baf0c606870c to your computer and use it in GitHub Desktop.
def kpi(campaigns)
{
unique_views: campaigns.sum(:unique_views),
clicks: campaigns.sum(:clicker),
sent: campaigns.sum(:sent),
turnover: campaigns.sum(:turnover),
cost: campaigns.sum(:cost),
margin: campaigns.sum(:margin),
active_sent: active_campaigns.sum(:sent),
active_margin: active_campaigns.sum(:margin),
}
end
kpi(DbCampaigns.by_month(1, year: 2016))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment