Exemplo n.º 1
0
 protected function logImpressionsStatisticsData($tld, $total_bids, $spend_offered_in_bids)
 {
     if ($this->RtbBidRequest != null) {
         /*
          * CREATE AN HOURLY TALLY OF INCOMING RTB BIDS
          * FROM BOTH LOCAL PUBS AND REMOTE SSP RTB SITE ID
          * CHANNELS IN ORDER TO PROVIDE THE SITE SCOUT
          * RTB CHANNEL CHOOSER FUNCTIONALITY IN AN EXCEL LIKE
          * GRID LAYOUT WITH THE DAILY IMPS IN A SORTABLE COLUMN
          */
         $buyside_partner_name = $this->rtb_ssp_friendly_name;
         $rtb_channel_site_domain = $tld;
         $auction_bids_counter = $total_bids;
         $rtb_ids = \util\WorkflowHelper::getIdsFromRtbRequest($this->RtbBidRequest);
         $rtb_channel_site_id = $rtb_ids["rtb_channel_site_id"];
         $rtb_channel_site_name = $rtb_ids["rtb_channel_site_name"];
         $rtb_channel_publisher_name = $rtb_ids["rtb_channel_publisher_name"];
         $rtb_channel_site_iab_category = $rtb_ids["rtb_channel_site_iab_category"];
         $impressions_offered_counter = $rtb_ids["impressions_offered_counter"];
         $floor_price_if_any = 0;
         if (isset($this->RtbBidRequest->RtbBidRequestImpList) && is_array($this->RtbBidRequest->RtbBidRequestImpList)) {
             foreach ($this->RtbBidRequest->RtbBidRequestImpList as $RtbBidRequestImp) {
                 if (isset($RtbBidRequestImp->bidfloor) && $RtbBidRequestImp->bidfloor > $floor_price_if_any) {
                     $floor_price_if_any = floatval($RtbBidRequestImp->bidfloor);
                 }
             }
         }
         $method_params = array("buyside_partner_name" => $buyside_partner_name, "rtb_channel_site_id" => $rtb_channel_site_id, "rtb_channel_site_name" => $rtb_channel_site_name, "rtb_channel_site_domain" => $rtb_channel_site_domain, "rtb_channel_site_iab_category" => $rtb_channel_site_iab_category, "rtb_channel_publisher_name" => $rtb_channel_publisher_name, "impressions_offered_counter" => $impressions_offered_counter, "auction_bids_counter" => $auction_bids_counter, "spend_offered_in_bids" => $spend_offered_in_bids, "floor_price_if_any" => $floor_price_if_any);
         if ($this->is_local_request === true) {
             /*
              * In the local context, $rtb_channel_site_id is the PublisherWebsiteID
              */
             $PrivateExchangeRtbChannelDailyStatsFactory = \_factory\PrivateExchangeRtbChannelDailyStats::get_instance();
             $PrivateExchangeRtbChannelDailyStatsFactory->incrementPrivateExchangeRtbChannelDailyStatsCached($this->config, $method_params);
         } else {
             $SspRtbChannelDailyStatsFactory = \_factory\SspRtbChannelDailyStats::get_instance();
             $SspRtbChannelDailyStatsFactory->incrementSspRtbChannelDailyStatsCached($this->config, $method_params);
         }
     }
 }
Exemplo n.º 2
0
 public function incrementSspRtbChannelDailyStats($config, $current)
 {
     if (!is_array($current)) {
         return;
     }
     $SspRtbChannelDailyStatsFactory = \_factory\SspRtbChannelDailyStats::get_instance();
     foreach ($current as $rtb_channel_site_id => $method_params) {
         if (!isset($method_params["buyside_partner_name"])) {
             continue;
         }
         $buyside_partner_name = $method_params["buyside_partner_name"];
         $rtb_channel_site_id = $method_params["rtb_channel_site_id"];
         $rtb_channel_site_name = $method_params["rtb_channel_site_name"];
         $rtb_channel_site_domain = $method_params["rtb_channel_site_domain"];
         $rtb_channel_site_iab_category = $method_params["rtb_channel_site_iab_category"];
         $rtb_channel_publisher_name = $method_params["rtb_channel_publisher_name"];
         $impressions_offered_counter = $method_params["impressions_offered_counter"];
         $auction_bids_counter = $method_params["auction_bids_counter"];
         $spend_offered_in_bids = $method_params["spend_offered_in_bids"];
         $floor_price_if_any = $method_params["floor_price_if_any"];
         $current_hour = date("m/d/Y H");
         $current_day = date("m/d/Y");
         $params = array();
         $params["BuySidePartnerName"] = $buyside_partner_name;
         $params["SspRtbChannelSiteID"] = $rtb_channel_site_id;
         $params["MDYH"] = $current_hour;
         $SspRtbChannelDailyStats = $SspRtbChannelDailyStatsFactory->get_row($params);
         $ssp_rtb_channel_daily_stats = new \model\SspRtbChannelDailyStats();
         $ssp_rtb_channel_daily_stats->BuySidePartnerName = $buyside_partner_name;
         $ssp_rtb_channel_daily_stats->SspRtbChannelSiteID = $rtb_channel_site_id;
         $ssp_rtb_channel_daily_stats->SspRtbChannelSiteName = $rtb_channel_site_name;
         $ssp_rtb_channel_daily_stats->SspRtbChannelSiteDomain = $rtb_channel_site_domain;
         $ssp_rtb_channel_daily_stats->SspRtbChannelSiteIABCategory = $rtb_channel_site_iab_category;
         $ssp_rtb_channel_daily_stats->SspRtbChannelPublisherName = $rtb_channel_publisher_name;
         $ssp_rtb_channel_daily_stats->BidFloor = $floor_price_if_any;
         if ($SspRtbChannelDailyStats != null) {
             $ssp_rtb_channel_daily_stats->SspRtbChannelDailyStatsID = $SspRtbChannelDailyStats->SspRtbChannelDailyStatsID;
             $ssp_rtb_channel_daily_stats->ImpressionsOfferedCounter = $SspRtbChannelDailyStats->ImpressionsOfferedCounter + $impressions_offered_counter;
             $ssp_rtb_channel_daily_stats->AuctionBidsCounter = $SspRtbChannelDailyStats->AuctionBidsCounter + $auction_bids_counter;
             $ssp_rtb_channel_daily_stats->BidTotalAmount = $SspRtbChannelDailyStats->BidTotalAmount + $spend_offered_in_bids;
             $SspRtbChannelDailyStatsFactory->updateSspRtbChannelDailyStats($ssp_rtb_channel_daily_stats);
         } else {
             $ssp_rtb_channel_daily_stats->MDYH = $current_hour;
             $ssp_rtb_channel_daily_stats->MDY = $current_day;
             $ssp_rtb_channel_daily_stats->ImpressionsOfferedCounter = $impressions_offered_counter;
             $ssp_rtb_channel_daily_stats->AuctionBidsCounter = $auction_bids_counter;
             $ssp_rtb_channel_daily_stats->BidTotalAmount = $spend_offered_in_bids;
             $ssp_rtb_channel_daily_stats->DateCreated = date("Y-m-d H:i:s");
             $SspRtbChannelDailyStatsFactory->insertSspRtbChannelDailyStats($ssp_rtb_channel_daily_stats);
         }
     }
 }
Exemplo n.º 3
0
 protected function logImpressionsStatisticsData($tld, $total_bids, $spend_offered_in_bids)
 {
     if ($this->RtbBidRequest != null) {
         /*
          * CREATE AN HOURLY TALLY OF INCOMING RTB BIDS
          * FROM BOTH LOCAL PUBS AND REMOTE SSP RTB SITE ID
          * CHANNELS IN ORDER TO PROVIDE THE SITE SCOUT
          * RTB CHANNEL CHOOSER FUNCTIONALITY IN AN EXCEL LIKE
          * GRID LAYOUT WITH THE DAILY IMPS IN A SORTABLE COLUMN
          */
         $buyside_partner_name = $this->rtb_ssp_friendly_name;
         $rtb_channel_site_id = "N/A";
         $rtb_channel_site_name = "N/A";
         $rtb_channel_publisher_name = "N/A";
         $rtb_channel_site_domain = $tld;
         $rtb_channel_site_iab_category = null;
         $impressions_offered_counter = 0;
         $auction_bids_counter = $total_bids;
         if (isset($this->RtbBidRequest->RtbBidRequestSite->id)) {
             $rtb_channel_site_id = $this->RtbBidRequest->RtbBidRequestSite->id;
         } elseif (isset($this->RtbBidRequest->RtbBidRequestApp->id)) {
             $rtb_channel_site_id = $this->RtbBidRequest->RtbBidRequestApp->id;
         }
         if (isset($this->RtbBidRequest->RtbBidRequestSite->name)) {
             $rtb_channel_site_name = $this->RtbBidRequest->RtbBidRequestSite->name;
         } elseif (isset($this->RtbBidRequest->RtbBidRequestApp->name)) {
             $rtb_channel_site_name = $this->RtbBidRequest->RtbBidRequestApp->name;
         }
         if (isset($this->RtbBidRequest->RtbBidRequestSite->RtbBidRequestPublisher->name)) {
             $rtb_channel_publisher_name = $this->RtbBidRequest->RtbBidRequestSite->RtbBidRequestPublisher->name;
         } elseif (isset($this->RtbBidRequest->RtbBidRequestApp->RtbBidRequestPublisher->name)) {
             $rtb_channel_publisher_name = $this->RtbBidRequest->RtbBidRequestApp->RtbBidRequestPublisher->name;
         }
         if (isset($this->RtbBidRequest->RtbBidRequestSite->cat[0])) {
             $rtb_channel_site_iab_category = $this->RtbBidRequest->RtbBidRequestSite->cat[0];
         } elseif (isset($this->RtbBidRequest->RtbBidRequestApp->cat[0])) {
             $rtb_channel_site_iab_category = $this->RtbBidRequest->RtbBidRequestApp->cat[0];
         }
         if ($rtb_channel_site_iab_category === null && isset($this->RtbBidRequest->RtbBidRequestSite->sectioncat[0])) {
             $rtb_channel_site_iab_category = $this->RtbBidRequest->RtbBidRequestSite->sectioncat[0];
         } elseif ($rtb_channel_site_iab_category === null && isset($this->RtbBidRequest->RtbBidRequestApp->sectioncat[0])) {
             $rtb_channel_site_iab_category = $this->RtbBidRequest->RtbBidRequestApp->sectioncat[0];
         }
         if ($rtb_channel_site_iab_category === null && isset($this->RtbBidRequest->RtbBidRequestSite->pagecat[0])) {
             $rtb_channel_site_iab_category = $this->RtbBidRequest->RtbBidRequestSite->pagecat[0];
         } elseif ($rtb_channel_site_iab_category === null && isset($this->RtbBidRequest->RtbBidRequestApp->pagecat[0])) {
             $rtb_channel_site_iab_category = $this->RtbBidRequest->RtbBidRequestApp->pagecat[0];
         }
         if ($rtb_channel_site_iab_category !== null) {
             $rtb_channel_site_iab_category = array_search($rtb_channel_site_iab_category, \buyrtb\parsers\openrtb\parselets\common\ParseWebsite::$vertical_map);
         }
         if ($rtb_channel_site_iab_category === null || $rtb_channel_site_iab_category === false) {
             $rtb_channel_site_iab_category = "N/A";
         }
         if (isset($this->RtbBidRequest->RtbBidRequestImpList) && is_array($this->RtbBidRequest->RtbBidRequestImpList)) {
             $impressions_offered_counter = count($this->RtbBidRequest->RtbBidRequestImpList);
         }
         $floor_price_if_any = 0;
         if (isset($this->RtbBidRequest->RtbBidRequestImpList) && is_array($this->RtbBidRequest->RtbBidRequestImpList)) {
             foreach ($this->RtbBidRequest->RtbBidRequestImpList as $RtbBidRequestImp) {
                 if (isset($RtbBidRequestImp->bidfloor) && $RtbBidRequestImp->bidfloor > $floor_price_if_any) {
                     $floor_price_if_any = floatval($RtbBidRequestImp->bidfloor);
                 }
             }
         }
         $method_params = array("buyside_partner_name" => $buyside_partner_name, "rtb_channel_site_id" => $rtb_channel_site_id, "rtb_channel_site_name" => $rtb_channel_site_name, "rtb_channel_site_domain" => $rtb_channel_site_domain, "rtb_channel_site_iab_category" => $rtb_channel_site_iab_category, "rtb_channel_publisher_name" => $rtb_channel_publisher_name, "impressions_offered_counter" => $impressions_offered_counter, "auction_bids_counter" => $auction_bids_counter, "spend_offered_in_bids" => $spend_offered_in_bids, "floor_price_if_any" => $floor_price_if_any);
         if ($this->is_local_request === true) {
             /*
              * In the local context, $rtb_channel_site_id is the PublisherWebsiteID
              */
             $PrivateExchangeRtbChannelDailyStatsFactory = \_factory\PrivateExchangeRtbChannelDailyStats::get_instance();
             $PrivateExchangeRtbChannelDailyStatsFactory->incrementPrivateExchangeRtbChannelDailyStatsCached($this->config, $method_params);
         } else {
             $SspRtbChannelDailyStatsFactory = \_factory\SspRtbChannelDailyStats::get_instance();
             $SspRtbChannelDailyStatsFactory->incrementSspRtbChannelDailyStatsCached($this->config, $method_params);
         }
     }
 }