Created
December 7, 2017 12:12
-
-
Save crova/3a5f5f60cbf9703e32971c4b5227aa1a to your computer and use it in GitHub Desktop.
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 update | |
| # Calculate the KPIs for a single_shoot | |
| @single_shoot = SibCampaign.find_by_id(params[:id]) | |
| @single_shoot.orate = (@single_shoot.unique_views / @single_shoot.sent) * 100 | |
| if @single_shoot.update_attributes(single_shoot_params) | |
| @single_shoot = SibCampaign.find_by_id(params[:id]) | |
| @single_shoot.cost = (@single_shoot.sent * @single_shoot.cpm) / 1000 | |
| @single_shoot.turnover = @single_shoot.result * @single_shoot.payout | |
| @single_shoot.margin = (@single_shoot.turnover - @single_shoot.cost) | |
| @single_shoot.ecpm = (@single_shoot.margin / @single_shoot.sent) * 1000 | |
| @single_shoot.roi = ((@single_shoot.turnover - @single_shoot.cost) / @single_shoot.cost) * 100 | |
| opens = @single_shoot.unique_views + 0.0 | |
| clicks = @single_shoot.clicker + 0.0 | |
| volume = @single_shoot.sent + 0.0 | |
| @single_shoot.orate = (opens / volume) * 100 | |
| @single_shoot.crate = (clicks / volume) * 100 | |
| end | |
| @single_shoot = SibCampaign.find_by_id(params[:id]) | |
| if @single_shoot.update_attributes(db_campaigns) | |
| flash[:notice] = "Shoot updated successfully." | |
| redirect_to(:action => 'show', :id => @single_shoot.id) | |
| end | |
| end | |
| private | |
| def single_shoot_params | |
| params.permit(:campaign_id, :campaign_name, :subject, :bat_sent, :html_content, :entered, :modified, :status, :sent, :remaining, :listid, :exclude_list, :stats_by_domain, :scheduled_date, :filter, :tags, :header, :footer, :to_field, :from_name, :from_email, :form_name, :reply_to, :delivered, :unique_views, :viewed, :clicked, :clicker, :hard_bounce, :soft_bounce, :unsub, :mirror_click, :complaints, :links_message, :share_link, :payout, :ecpm, :turnover, :cost, :margin, :result, :roi, :name, :segment, :deal, :partner, :cpm, :sender, :gender, :scenario, :theme, :segment_data, :segments_query_txt, :mongo_query, :html_content, :from_name, :from_email, :tags, :form_name, :stats_by_domain) | |
| end | |
| def db_campaigns | |
| params.permit(:campaign_id, :campaign_name, :subject, :bat_sent, :html_content, :entered, :modified, :status, :sent, :remaining, :listid, :exclude_list, :stats_by_domain, :scheduled_date, :filter, :tags, :header, :footer, :to_field, :from_name, :from_email, :form_name, :reply_to, :delivered, :unique_views, :viewed, :clicked, :clicker, :hard_bounce, :soft_bounce, :unsub, :mirror_click, :complaints, :links_message, :share_link, :payout, :ecpm, :turnover, :cost, :margin, :result, :roi, :name, :segment, :deal, :partner, :cpm, :sender, :gender, :scenario, :theme, :segment_data, :segments_query_txt, :mongo_query, :html_content, :from_name, :from_email, :tags, :form_name, :stats_by_domain) | |
| end | |
| def sib_campaign_params | |
| params.fetch(:sib_campaign, {}) | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment