Exemplo n.º 1
0
 /**
  * This method returns zone statistics for an advertiser for a specified period.
  *
  * @access public
  *
  * @param integer $advertiserId The ID of the advertiser to view statistics for
  * @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>publisherID integer</b> The ID of the publisher
  *   <li><b>publisherName string (255)</b> The name of the publisher
  *   <li><b>zoneID integer</b> The ID of the zone
  *   <li><b>zoneName string (255)</b> The name of the zone
  *   <li><b>requests integer</b> The number of requests for the day
  *   <li><b>impressions integer</b> The number of impressions for the day
  *   <li><b>clicks integer</b> The number of clicks for the day
  *   <li><b>revenue decimal</b> The revenue earned for the day
  *   </ul>
  *
  * @return boolean  True if the operation was successful and false if not.
  *
  */
 function getAdvertiserZoneStatistics($advertiserId, $oStartDate, $oEndDate, $localTZ, &$rsStatisticsData)
 {
     if (!$this->checkStatisticsPermissions($advertiserId)) {
         return false;
     }
     if ($this->_validateForStatistics($advertiserId, $oStartDate, $oEndDate)) {
         $dalAdvertiser = new OA_Dal_Statistics_Advertiser();
         $rsStatisticsData = $dalAdvertiser->getAdvertiserZoneStatistics($advertiserId, $oStartDate, $oEndDate, $localTZ);
         return true;
     } else {
         return false;
     }
 }
Exemplo n.º 2
0
 /**
  * Test advertiser zone statistics.
  *
  */
 function testGetAdvertiserZoneStatistics()
 {
     $doAgency = OA_Dal::factoryDO('agency');
     $doAdvertiser = OA_Dal::factoryDO('clients');
     $doCampaign = OA_Dal::factoryDO('campaigns');
     $doBanner1 = OA_Dal::factoryDO('banners');
     $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');
     $doPublisher->name = "Test publisher name 1";
     $doZone->zonename = "Test zone name 1";
     $this->generateZoneWithParents($doAgency, $doPublisher, $doZone);
     $doDataSummaryAdHourly = OA_Dal::factoryDO('data_summary_ad_hourly');
     $doDataSummaryAdHourly->impressions = 11;
     $doDataSummaryAdHourly->requests = 22;
     $doDataSummaryAdHourly->total_revenue = 33;
     $doDataSummaryAdHourly->clicks = 44;
     $doDataSummaryAdHourly->date_time = '1983-08-14';
     $this->generateDataSummaryAdHourlyForBannerAndZone($doDataSummaryAdHourly, $doBanner1, $doZone);
     $doDataSummaryAdHourly = OA_Dal::factoryDO('data_summary_ad_hourly');
     $doDataSummaryAdHourly->impressions = 1;
     $doDataSummaryAdHourly->requests = 2;
     $doDataSummaryAdHourly->total_revenue = 3;
     $doDataSummaryAdHourly->clicks = 4;
     $doDataSummaryAdHourly->date_time = '2007-09-13';
     $this->generateDataSummaryAdHourlyForBannerAndZone($doDataSummaryAdHourly, $doBanner2, $doZone);
     // 1. Get data existing range
     $rsAdvertiserStatistics = $this->_dalAdvertiserStatistics->getAdvertiserZoneStatistics($doAdvertiser->clientid, new Date('1983-01-01'), new Date('2007-09-18'));
     $rsAdvertiserStatistics->find();
     $this->assertTrue($rsAdvertiserStatistics->getRowCount() == 1, 'Some records should be returned');
     $rsAdvertiserStatistics->fetch();
     $aRow = $rsAdvertiserStatistics->toArray();
     // 2. Check return fields names
     $this->assertFieldExists($aRow, 'publisherid');
     $this->assertFieldExists($aRow, 'publishername');
     $this->assertFieldExists($aRow, 'zoneid');
     $this->assertFieldExists($aRow, 'zonename');
     $this->assertFieldExists($aRow, 'requests');
     $this->assertFieldExists($aRow, 'impressions');
     $this->assertFieldExists($aRow, 'clicks');
     $this->assertFieldExists($aRow, 'revenue');
     // 3. Check return fields value
     $this->assertFieldEqual($aRow, 'impressions', 12);
     $this->assertFieldEqual($aRow, 'requests', 24);
     $this->assertFieldEqual($aRow, 'revenue', 36);
     $this->assertFieldEqual($aRow, 'clicks', 48);
     $this->assertFieldEqual($aRow, 'publishername', $doPublisher->name);
     $this->assertFieldEqual($aRow, 'zonename', $doZone->zonename);
     // 4. Get data in not existing range
     $rsAdvertiserStatistics = $this->_dalAdvertiserStatistics->getAdvertiserZoneStatistics($doAdvertiser->clientid, new Date('2007-09-21'), new Date('2007-09-21'));
     $rsAdvertiserStatistics->find();
     $this->assertTrue($rsAdvertiserStatistics->getRowCount() == 0, 'Recordset should be empty');
     // 5. Get data from only 1 advertiser
     $rsAdvertiserStatistics = $this->_dalAdvertiserStatistics->getAdvertiserZoneStatistics($doAdvertiser->clientid, new Date('1983-01-01'), new Date('1983-09-01'));
     $rsAdvertiserStatistics->find();
     $this->assertTrue($rsAdvertiserStatistics->getRowCount() == 1, 'Some records should be returned');
     $rsAdvertiserStatistics->fetch();
     $aRow = $rsAdvertiserStatistics->toArray();
     $this->assertFieldEqual($aRow, 'impressions', 11);
 }