Exemplo n.º 1
0
 /**
  * Test zone daily statistics.
  *
  */
 function testGetZoneDailyStatistics()
 {
     $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 = 121;
     $doDataSummaryAdHourly->requests = 223;
     $doDataSummaryAdHourly->total_revenue = 433;
     $doDataSummaryAdHourly->clicks = 9894;
     $doDataSummaryAdHourly->date_time = '2006-06-06';
     $this->generateDataSummaryAdHourlyForZone($doDataSummaryAdHourly, $doZone);
     // 1. Get data existing range
     $aData = $this->_dalZoneStatistics->getZoneDailyStatistics($doZone->zoneid, new Date('2005-08-20'), new Date('2007-08-20'));
     $this->assertEqual(count($aData), 1, 'Some records should be returned');
     $aRow = current($aData);
     // 2. Check return fields names
     $this->assertFieldExists($aRow, 'day');
     $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', 121);
     $this->assertFieldEqual($aRow, 'requests', 223);
     $this->assertFieldEqual($aRow, 'revenue', 433);
     $this->assertFieldEqual($aRow, 'clicks', 9894);
     $this->assertFieldEqual($aRow, 'day', '2006-06-06');
     // 4. Get data in not existing range
     $aData = $this->_dalZoneStatistics->getZoneDailyStatistics($doZone->zoneid, new Date('2001-12-01'), new Date('2006-01-19'));
     $this->assertEqual(count($aData), 0, 'Recordset should be empty');
 }
Exemplo n.º 2
0
 /**
  * This method returns daily 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>day date</b> The day
  *   <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 getZoneDailyStatistics($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->getZoneDailyStatistics($zoneId, $oStartDate, $oEndDate, $localTZ);
         return true;
     } else {
         return false;
     }
 }