# module AdCampaignsHelper
#   def campaign_brought_in_users(campaign, medium)
#     User.where(origin_utm_campaign: campaign, origin_utm_medium: medium)
#   end
# end

# ActiveAdmin.register JamRuby::AdCampaign do
#   permit_params :campaign, :medium, :spend
# end

# ActiveAdmin.register_page "Ad campaigns" do
#   menu parent: 'Reports'
#   content :title => "Paid Advertising Report" do
#     table_for User.select("users.origin_utm_campaign, users.origin_utm_medium, COALESCE(MAX(ad_campaigns.end_date), NULL) AS end_date, COALESCE(MAX(ad_campaigns.spend), NULL) AS spend").joins("LEFT JOIN ad_campaigns ON users.origin_utm_campaign = ad_campaigns.campaign AND users.origin_utm_medium = ad_campaigns.medium").group("ad_campaigns.id, users.origin_utm_campaign, users.origin_utm_medium") do
#       column "Campaign" do |campaign|
#         campaign.origin_utm_campaign
#       end
#       column "Medium" do |campaign|
#         campaign.origin_utm_medium
#       end
#       column "End Date" do |campaign|
#         campaign.end_date
#       end
#       column "Hard Date" do |campaign|
#         campaign.end_date + 45.days if campaign.end_date.present?
#       end
#       column "Subscribed" do |campaign|
#       end
#       column "Spend" do |campaign|
#         best_in_place  campaign, :spend, as: :input, url: admin_ad_campaigns_update_path(campaign: campaign.origin_utm_campaign, medium: campaign.origin_utm_medium), param: 'ad_campaign'
#       end
#     end
#   end

#   page_action :update, method: :put do
#     campaign = params[:campaign]
#     medium = params[:medium]
#     ad_campaign = AdCampaign.where(campaign: campaign, medium: medium).first_or_initialize
#     ad_campaign.attributes = params["ad_campaign"]
#     ad_campaign.save!
#     respond_with_bip(ad_campaign)
#   end
# end