Exemplo n.º 1
0
 /**
  * Test generating empty RecordSet
  *
  */
 function test_emptyRecordSet()
 {
     $rsEmpty = $this->_dalZoneStatistics->_emptyRecordSet();
     $this->assertIsA($rsEmpty, "MDB2RecordSet");
     $rsEmpty->find();
     $this->assertTrue($rsEmpty->getRowCount() == 0);
 }
Exemplo n.º 2
0
 /**
  * This method returns banner statistics for a zone for a specified period.
  *
  * @access public
  *
  * @param integer $zoneId The ID of the zone to view statistics
  * @param date $oStartDate The date from which to get statistics (inclusive)
  * @param date $oEndDate The date to which to get statistics (inclusive)
  * @param bool $localTZ Should stats be using the manager TZ or UTC?
  * @param array $rsStatisticsData The data returned by the function
  *   <ul>
  *   <li><b>bannerID integer</b> The ID of the banner
  *   <li><b>bannerName string (255)</b> The name of the banner
  *   <li><b>campaignID integer</b> The ID of the banner
  *   <li><b>campaignName string (255)</b> The name of the banner
  *   <li><b>advertiserID integer</b> The ID of the advertiser
  *   <li><b>advertiserName string</b> The name of the advertiser
  *   <li><b>requests integer</b> The number of requests for the banner
  *   <li><b>impressions integer</b> The number of impressions for the banner
  *   <li><b>clicks integer</b> The number of clicks for the banner
  *   <li><b>revenue decimal</b> The revenue earned for the banner
  *   </ul>
  *
  * @return boolean True if the operation was successful and false if not.
  *
  */
 function getZoneBannerStatistics($zoneId, $oStartDate, $oEndDate, $localTZ, &$rsStatisticsData)
 {
     if (!$this->checkStatisticsPermissions($zoneId)) {
         return false;
     }
     if ($this->_validateForStatistics($zoneId, $oStartDate, $oEndDate)) {
         $dalZone = new OA_Dal_Statistics_Zone();
         $rsStatisticsData = $dalZone->getZoneBannerStatistics($zoneId, $oStartDate, $oEndDate, $localTZ);
         return true;
     } else {
         return false;
     }
 }
Exemplo n.º 3
0
 /**
  * Adds statistics data to array of websites and zones ($aWebsitesAndZones)
  *
  * @param array &$aZones array of websites and zones - result of getWebsitesAndZonesList
  * @param int $campaignId campaign Id.
  */
 function mergeStatistics(&$aWebsitesAndZones, $campaignId)
 {
     // Get list of zones IDs
     $aZonesIDs = array();
     $aZonesWebsite = array();
     foreach ($aWebsitesAndZones as $websiteId => $aWebsite) {
         foreach (array_keys($aWebsite['zones']) as $zoneId) {
             $aZonesIDs[] = $zoneId;
             $aZonesWebsite[$zoneId] = $websiteId;
         }
     }
     // Get statistics for zones for this campaign
     $oOaDalStatisticsZone = new OA_Dal_Statistics_Zone();
     $aZoneCampaignStatistics = $oOaDalStatisticsZone->getZonesPerformanceStatistics($aZonesIDs, $campaignId);
     if (isset($campaignId)) {
         // If there are zones that have no statistics for campaign, calculate overall statistics
         $aZoneWithMissingStatsIds = array();
         foreach ($aZonesIDs as $zoneId) {
             if (!isset($aZoneCampaignStatistics[$zoneId]['CTR']) && !isset($aZoneCampaignStatistics[$zoneId]['CR']) && !isset($aZoneCampaignStatistics[$zoneId]['eCPM'])) {
                 $aZoneWithMissingStatsIds[] = $zoneId;
             }
         }
         $aZoneGlobalStatistics = $oOaDalStatisticsZone->getZonesPerformanceStatistics($aZoneWithMissingStatsIds);
     } else {
         // If campaign ID isn't given it means, that overall statistics was calculated
         $aZoneGlobalStatistics = $aZoneCampaignStatistics;
         $aZoneCampaignStatistics = array();
     }
     foreach ($aZonesWebsite as $zoneId => $websiteId) {
         if (isset($aZoneGlobalStatistics[$zoneId])) {
             $aWebsitesAndZones[$websiteId]['zones'][$zoneId]['campaign_stats'] = false;
             $aWebsitesAndZones[$websiteId]['zones'][$zoneId]['ecpm'] = $aZoneGlobalStatistics[$zoneId]['eCPM'];
             $aWebsitesAndZones[$websiteId]['zones'][$zoneId]['cr'] = $aZoneGlobalStatistics[$zoneId]['CR'];
             $aWebsitesAndZones[$websiteId]['zones'][$zoneId]['ctr'] = $aZoneGlobalStatistics[$zoneId]['CTR'];
         } else {
             $aWebsitesAndZones[$websiteId]['zones'][$zoneId]['campaign_stats'] = true;
             $aWebsitesAndZones[$websiteId]['zones'][$zoneId]['ecpm'] = $aZoneCampaignStatistics[$zoneId]['eCPM'];
             $aWebsitesAndZones[$websiteId]['zones'][$zoneId]['cr'] = $aZoneCampaignStatistics[$zoneId]['CR'];
             $aWebsitesAndZones[$websiteId]['zones'][$zoneId]['ctr'] = $aZoneCampaignStatistics[$zoneId]['CTR'];
         }
     }
 }
Exemplo n.º 4
0
 /**
  * Adds statistics data to array of zones ($aZones)
  *
  * @param array &$aZones array of zones - result of getZonesListByCategory
  * @param int $campaignId campaign Id.
  */
 function _getStatistics(&$aZones, $campaignId)
 {
     // Get list of zones IDs
     $aZonesIDs = array();
     foreach ($aZones as $k => $aZone) {
         $aZonesIDs[] = $aZone['zoneid'];
     }
     // Get statistics for zones for this campaign
     $oOaDalStatisticsZone = new OA_Dal_Statistics_Zone();
     $aZoneCampaignStatistics = $oOaDalStatisticsZone->getZonesPerformanceStatistics($aZonesIDs, $campaignId);
     if (!is_null($campaignId)) {
         // If there are zones that have no statistics for campaign, calculate overall statistics
         $aZoneWithMissingStatsIds = array();
         foreach ($aZones as $k => $aZone) {
             if (is_null($aZoneCampaignStatistics[$aZone['zoneid']]['CTR']) && is_null($aZoneCampaignStatistics[$aZone['zoneid']]['CR']) && is_null($aZoneCampaignStatistics[$aZone['zoneid']]['eCPM'])) {
                 $aZoneWithMissingStatsIds[] = $aZone['zoneid'];
             }
         }
         $aZoneGlobalStatistics = $oOaDalStatisticsZone->getZonesPerformanceStatistics($aZoneWithMissingStatsIds);
     } else {
         // If campaign ID isn't given it means, that overall statistics was calculated
         $aZoneGlobalStatistics = $aZoneCampaignStatistics;
         $aZoneCampaignStatistics = array();
     }
     foreach ($aZones as $k => $aZone) {
         $zoneid = $aZones[$k]['zoneid'];
         if (array_key_exists($aZones[$k]['zoneid'], $aZoneGlobalStatistics)) {
             $aZones[$k]['campaign_stats'] = false;
             $aZones[$k]['ecpm'] = $aZoneGlobalStatistics[$zoneid]['eCPM'];
             $aZones[$k]['cr'] = $aZoneGlobalStatistics[$zoneid]['CR'];
             $aZones[$k]['ctr'] = $aZoneGlobalStatistics[$zoneid]['CTR'];
         } else {
             $aZones[$k]['campaign_stats'] = true;
             $aZones[$k]['ecpm'] = $aZoneCampaignStatistics[$zoneid]['eCPM'];
             $aZones[$k]['cr'] = $aZoneCampaignStatistics[$zoneid]['CR'];
             $aZones[$k]['ctr'] = $aZoneCampaignStatistics[$zoneid]['CTR'];
         }
     }
 }