This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class CampaignController < ApplicationController | |
def index | |
@campaigns = Campaign.all.sorted.paginate(:page => params[:page], :per_page => 10) | |
end | |
def show | |
@single_shoot = Campaign.find(params[:id]) | |
# KPIs | |
# |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<tr> | |
<th><%= f.label(:deal) %></th> | |
<td><%= f.select(:deal, options_for_select([['CPL', 'CPL'], ['CPC', 'CPC'], ['CPM', 'CPM'], ['CTL', 'CTL'], ['CPA', 'CPA']]), :value => @single_shoot.deal) %></td> | |
</tr> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def campaign_query | |
@campaign_query = Shoot.all | |
end | |
def campaign_trial | |
@campaign_trial = campaign_query.order("id ASC") | |
end | |
def needed_campaign_records | |
@needed_campaign_records ||= campaign_trial.map | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
day = Time.current.day | |
day_to_use = day - 1 | |
month = Time.current.month | |
#sets number of days within current month | |
if month == 4 || 6 || 9 || 11 | |
days_within_month = 30 | |
elsif month == 1 || 3 || 5 || 7 || 8 || 10 || 12 | |
days_within_month = 31 | |
else | |
days_within_month = 28 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# fetchs SIB Account information | |
def sib_account_fetch | |
sib = Mailin.new("API_URL","API_KEY") | |
acct = sib.get_account() | |
acct.dig('data') | |
credits = acct.dig('data', 0).to_h | |
SibAccount.find(1).update_attributes(credits) | |
details = acct.dig('data', 2).to_h | |
SibAccount.find(1).update_attributes(details).delay |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Fetchs campaigns from SiB | |
class CampaignFetch | |
def get | |
def sib | |
@sib ||= Mailin.new("API_URL","API_KEY") | |
end | |
def shoot_criteria | |
{ "type"=>"classic", "status" => "sent", "page"=>10,"page_limit"=>1000 } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Generates KPIs for each Month - Year 2016 | |
#january kpis | |
camp_january_2016 = DbCampaign.where('extract(month from scheduled_date) = ?', 01).where('extract(year from scheduled_date) = ?', 2016) | |
camp_january_actifs_2016 = DbCampaign.where('extract(month from scheduled_date) = ?', 01).where('extract(year from scheduled_date) = ?', 2016).where(:segment_2016 => "Actifs") | |
jan_o_2016 = camp_january_2016.pluck('unique_views').sum | |
jan_opens_2016 = jan_o_2016 + 0.0 | |
jan_c_2016 = camp_january_2016.pluck('clicker').sum | |
jan_clicks_2016 = jan_c_2016 + 0.0 | |
jan_v_2016 = camp_january_2016.pluck('sent').sum | |
jan_volume_2016 = jan_v + 0.0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
wp_link_pages( array( | |
'before' => '<div class="page-links"><center><p id="post-navigator">' . esc_html__( '', 'extra' ), | |
'after' => '</p></center></div>', | |
'next_or_number'=>'next', | |
'previouspagelink'=>'« Página anterior', | |
'nextpagelink'=>'Continuar lendo »', | |
) ); | |
?> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[{"Stat"=>{"affiliate_info1"=>nil, "approved_payout"=>"277.000000"}, "Offer"=>{"name"=>"Johnson&Johnson Promo - BR"}}, {"Stat"=>{"affiliate_info1"=>"", "approved_payout"=>"99.003150"}, "Offer"=>{"name"=>"Toluna - BR"}}, {"Stat"=>{"affiliate_info1"=>"", "approved_payout"=>"54.000000"}, "Offer"=>{"name"=>"eCGlobal - 168742 - Tecnologia - BR"}}, {"Stat"=>{"affiliate_info1"=>"", "approved_payout"=>"11.850000"}, "Offer"=>{"name"=>"Clube da Lu - BR"}}, {"Stat"=>{"affiliate_info1"=>"", "approved_payout"=>"81.250000"}, "Offer"=>{"name"=>"Conecta í Uber - BR"}}, {"Stat"=>{"affiliate_info1"=>"BASE", "approved_payout"=>"104.751760"}, "Offer"=>{"name"=>"Global Test Market - BR"}}, {"Stat"=>{"affiliate_info1"=>"SUBID", "approved_payout"=>"10.500000"}, "Offer"=>{"name"=>"Eudora - BR"}}, {"Stat"=>{"affiliate_info1"=>"SUBID", "approved_payout"=>"397.928968"}, "Offer"=>{"name"=>"Angela - BR"}}, {"Stat"=>{"affiliate_info1"=>"subid", "approved_payout"=>"498.369118"}, "Offer"=>{"name"=>"Mundo de Opiniões - BR"}}, {"Stat"=>{"affi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Fetchs campaigns from SiB | |
class SibCampaignFetcher | |
# fetchs SIB Campaigns | |
# Starts SiB Communication | |
def sib | |
@sib ||= Mailin.new("URL","APIKEY") | |
end | |
# Define the data to collect |