Ejemplo n.º 1
0
 /**
  * Test agency banner statistics.
  *
  */
 function testGetAgencyBannerStatistics()
 {
     $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);
     $doDataSummaryAdHourly = OA_Dal::factoryDO('data_summary_ad_hourly');
     $doDataSummaryAdHourly->impressions = 1;
     $doDataSummaryAdHourly->date_time = '2007-01-01';
     $this->generateDataSummaryAdHourlyForBanner($doDataSummaryAdHourly, $doBanner1);
     $doDataSummaryAdHourly = OA_Dal::factoryDO('data_summary_ad_hourly');
     $doDataSummaryAdHourly->impressions = 0;
     $doDataSummaryAdHourly->requests = 4;
     $doDataSummaryAdHourly->total_revenue = 6;
     $doDataSummaryAdHourly->clicks = 7;
     $doDataSummaryAdHourly->date_time = '2007-02-01';
     $this->generateDataSummaryAdHourlyForBanner($doDataSummaryAdHourly, $doBanner2);
     $doDataSummaryAdHourly = OA_Dal::factoryDO('data_summary_ad_hourly');
     $doDataSummaryAdHourly->impressions = 0;
     $doDataSummaryAdHourly->requests = 4;
     $doDataSummaryAdHourly->total_revenue = 6;
     $doDataSummaryAdHourly->clicks = 7;
     $doDataSummaryAdHourly->date_time = '2007-04-01';
     $this->generateDataSummaryAdHourlyForBanner($doDataSummaryAdHourly, $doBanner2);
     // 1. Get data existing range
     $rsAgencyStatistics = $this->_dalAgencyStatistics->getAgencyBannerStatistics($doAgency->agencyid, new Date('2006-07-07'), new Date('2007-09-12'));
     $rsAgencyStatistics->find();
     $this->assertTrue($rsAgencyStatistics->getRowCount() == 2, '2 records should be returned');
     $rsAgencyStatistics->fetch();
     $aRow1 = $rsAgencyStatistics->toArray();
     $rsAgencyStatistics->fetch();
     $aRow2 = $rsAgencyStatistics->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, 'impressions', 1);
     $this->assertFieldEqual($aRow2, 'impressions', 0);
     $this->assertFieldEqual($aRow2, 'requests', 8);
     $this->assertFieldEqual($aRow2, 'revenue', 12);
     $this->assertFieldEqual($aRow2, 'clicks', 14);
     // 4. Get data in not existing range
     $rsAgencyStatistics = $this->_dalAgencyStatistics->getAgencyBannerStatistics($doAgency->agencyid, new Date('2001-12-01'), new Date('2006-09-19'));
     $rsAgencyStatistics->find();
     $this->assertTrue($rsAgencyStatistics->getRowCount() == 0, 'Recordset should be empty');
 }
Ejemplo n.º 2
0
 /**
  * This method returns banner statistics for an agency for a specified period.
  *
  * @access public
  *
  * @param integer $agencyId The ID of the agency 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 array &$rsStatisticsData The data returned by the function
  * <ul>
  *   <li><b>advertiserID integer</b> The ID of the advertiser
  *   <li><b>advertiserName string (255)</b> The name of the advertiser
  *   <li><b>campaignID integer</b> The ID of the campaign
  *   <li><b>campaignName string (255)</b> The name of the campaign
  *   <li><b>bannerID integer</b> The ID of the banner
  *   <li><b>bannerName string (255)</b> The name of the banner
  *   <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 getAgencyBannerStatistics($agencyId, $oStartDate, $oEndDate, $localTZ, &$rsStatisticsData)
 {
     if (!$this->checkPermissions(array(OA_ACCOUNT_ADMIN, OA_ACCOUNT_MANAGER), 'agency', $agencyId)) {
         return false;
     }
     if ($this->_validateForStatistics($agencyId, $oStartDate, $oEndDate)) {
         $dalAgency = new OA_Dal_Statistics_Agency();
         $rsStatisticsData = $dalAgency->getAgencyBannerStatistics($agencyId, $oStartDate, $oEndDate, $localTZ);
         return true;
     } else {
         return false;
     }
 }