Skip to content

Instantly share code, notes, and snippets.

@oivoodoo
Created July 16, 2014 18:52
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 oivoodoo/3db7816793e5f14b9604 to your computer and use it in GitHub Desktop.
Save oivoodoo/3db7816793e5f14b9604 to your computer and use it in GitHub Desktop.
module V2
class ReportByCampaign < BaseReport
report 'campaign' do
attach_to DailyEventAd, as: 'ads' do
# We are using columns for resolving dynamic columns on rows
columns COLUMNS
# Fields Mapping is linking columns fields and row fields
mapping AD_FIELDS
filter promoted_app_id: ->(report) { { '$in' => report.app_ids } },
campaign_id: ->(report) { { '$exists' => true, '$ne' => nil } }
group_by :campaign_id
column :campaign_name, :impressions_received, :installs_received,
:clicks_received, :conv_rate, :clicks_thru_rate
end
end
report 'day' do
attach_to DailyEventAd, as: 'ads' do
# We are using columns for resolving dynamic columns on rows
columns COLUMNS
# Fields Mapping is linking columns fields and row fields
mapping AD_FIELDS
filter promoted_app_id: ->(report) { { '$in' => report.app_ids } },
campaign_id: ->(report) { { '$exists' => true, '$ne' => nil } }
group_by :day, :campaign_id
column :day, :impressions_received, :installs_received,
:clicks_received, :conv_rate, :clicks_thru_rate
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment