예제 #1
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;
     }
 }
예제 #2
0
 /**
  * Test zone banner statistics.
  *
  */
 function testGetZoneBannerStatistics()
 {
     $doAgency = OA_Dal::factoryDO('agency');
     $doAdvertiser = OA_Dal::factoryDO('clients');
     $doAdvertiser->clientname = 'advertiser name';
     $doCampaign = OA_Dal::factoryDO('campaigns');
     $doCampaign->campaignname = 'campaign name';
     $doBanner1 = OA_Dal::factoryDO('banners');
     $doBanner1->description = 'banner descrition';
     $this->generateBannerWithParents($doAgency, $doAdvertiser, $doCampaign, $doBanner1);
     $doBanner2 = OA_Dal::factoryDO('banners');
     $this->generateBannerForCampaign($doCampaign, $doBanner2);
     $doAgency = OA_Dal::factoryDO('agency');
     $doPublisher = OA_Dal::factoryDO('affiliates');
     $doZone = OA_Dal::factoryDO('zones');
     $this->generateZoneWithParents($doAgency, $doPublisher, $doZone);
     $doDataSummaryAdHourly = OA_Dal::factoryDO('data_summary_ad_hourly');
     $doDataSummaryAdHourly->impressions = 111;
     $doDataSummaryAdHourly->requests = 211;
     $doDataSummaryAdHourly->total_revenue = 311;
     $doDataSummaryAdHourly->clicks = 411;
     $doDataSummaryAdHourly->date_time = '2007-04-04';
     $this->generateDataSummaryAdHourlyForBannerAndZone($doDataSummaryAdHourly, $doBanner1, $doZone);
     $doDataSummaryAdHourly = OA_Dal::factoryDO('data_summary_ad_hourly');
     $doDataSummaryAdHourly->impressions = 10;
     $doDataSummaryAdHourly->requests = 11;
     $doDataSummaryAdHourly->total_revenue = 12;
     $doDataSummaryAdHourly->clicks = 13;
     $doDataSummaryAdHourly->date_time = '2007-10-08';
     $this->generateDataSummaryAdHourlyForBannerAndZone($doDataSummaryAdHourly, $doBanner1, $doZone);
     $doDataSummaryAdHourly = OA_Dal::factoryDO('data_summary_ad_hourly');
     $doDataSummaryAdHourly->impressions = 0;
     $doDataSummaryAdHourly->requests = 1;
     $doDataSummaryAdHourly->total_revenue = 22;
     $doDataSummaryAdHourly->clicks = 777;
     $doDataSummaryAdHourly->date_time = '2007-09-09';
     $this->generateDataSummaryAdHourlyForBannerAndZone($doDataSummaryAdHourly, $doBanner2, $doZone);
     // 1. Get data existing range
     $rsZoneStatistics = $this->_dalZoneStatistics->getZoneBannerStatistics($doZone->affiliateid, new Date('2007-01-06'), new Date('2007-11-18'));
     $rsZoneStatistics->find();
     $this->assertTrue($rsZoneStatistics->getRowCount() == 2, '2 records should be returned');
     $rsZoneStatistics->fetch();
     $aRow1 = $rsZoneStatistics->toArray();
     $rsZoneStatistics->fetch();
     $aRow2 = $rsZoneStatistics->toArray();
     $this->ensureRowSequence($aRow1, $aRow2, 'bannerid', $doBanner1->bannerid);
     // 2. Check return fields names
     $this->assertFieldExists($aRow1, 'advertiserid');
     $this->assertFieldExists($aRow1, 'advertisername');
     $this->assertFieldExists($aRow1, 'campaignid');
     $this->assertFieldExists($aRow1, 'campaignname');
     $this->assertFieldExists($aRow1, 'bannerid');
     $this->assertFieldExists($aRow1, 'bannername');
     $this->assertFieldExists($aRow1, 'requests');
     $this->assertFieldExists($aRow1, 'impressions');
     $this->assertFieldExists($aRow1, 'clicks');
     $this->assertFieldExists($aRow1, 'revenue');
     // 3. Check return fields value
     $this->assertFieldEqual($aRow1, 'advertisername', $doAdvertiser->clientname);
     $this->assertFieldEqual($aRow1, 'campaignname', $doCampaign->campaignname);
     $this->assertFieldEqual($aRow1, 'bannername', $doBanner1->description);
     $this->assertFieldEqual($aRow1, 'impressions', 121);
     $this->assertFieldEqual($aRow1, 'requests', 222);
     $this->assertFieldEqual($aRow2, 'revenue', 22);
     $this->assertFieldEqual($aRow2, 'clicks', 777);
     // 4. Get data in not existing range
     $rsZoneStatistics = $this->_dalZoneStatistics->getZoneBannerStatistics($doZone->affiliateid, new Date('2007-12-21'), new Date('2008-09-21'));
     $rsZoneStatistics->find();
     $this->assertTrue($rsZoneStatistics->getRowCount() == 0, 'Recordset should be empty');
 }