/** * A mathod to quickly check the data in the database for the date * range given, to ensure that the range being tested & corrected * seems reasonable. * * @param Date $oStartDate The start date/time of the range to test & correct. * @param Date $oEndDate The end date/time of the range to test & correct. * @return boolean True if the date range seems okay, false otherwise. */ function checkRangeData($oStartDate, $oEndDate) { // Test that there are no rows in the data_intermediate_ad table where the // operation interval value does not match that in the configuration file $doData_intermediate_ad = OA_Dal::factoryDO('data_intermediate_ad'); $doData_intermediate_ad->whereAdd('date_time >= ' . $this->oDbh->quote($oStartDate->format('%Y-%m-%d %H:%M:%S'), 'timestamp')); $doData_intermediate_ad->whereAdd('date_time <= ' . $this->oDbh->quote($oEndDate->format('%Y-%m-%d %H:%M:%S'), 'timestamp')); $doData_intermediate_ad->whereAdd('operation_interval != ' . $this->oDbh->quote(OX_OperationInterval::getOperationInterval(), 'integer')); $doData_intermediate_ad->find(); $rows = $doData_intermediate_ad->getRowCount(); if ($rows > 0) { $message = "\n Detected at least one row in the data_intermediate_ad table with operation interval != " . OX_OperationInterval::getOperationInterval() . ".\n"; echo $message; return false; } // Test that all of the date/time values in the data_summary_ad_hourly // table align with the start of operation intervals $doData_summary_ad_hourly = OA_Dal::factoryDO('data_summary_ad_hourly'); $doData_summary_ad_hourly->selectAdd(); $doData_summary_ad_hourly->selectAdd('DISTINCT date_time'); $doData_summary_ad_hourly->whereAdd('date_time >= ' . $this->oDbh->quote($oStartDate->format('%Y-%m-%d %H:%M:%S'), 'timestamp')); $doData_summary_ad_hourly->whereAdd('date_time <= ' . $this->oDbh->quote($oEndDate->format('%Y-%m-%d %H:%M:%S'), 'timestamp')); $doData_summary_ad_hourly->find(); while ($doData_summary_ad_hourly->fetch()) { $oDate = new Date($doData_summary_ad_hourly->date_time); $result = OX_OperationInterval::checkDateIsStartDate($oDate); if (!$result) { $message = "\n Detected at least one row in the data_summary_ad_hourly table with date_time value not on the hour start interval.\n"; echo $message; return false; } } return true; }
echo "\nPlease ensure that you have read the comments in the {$scriptName} script.\n\nYou will also find out how to make this script work by reading the comments. :-)\n"; echo $haltMessage; exit; } // Initialise the script RV::disableErrorHandling(); $result = OX_OperationInterval::checkOperationIntervalValue(OX_OperationInterval::getOperationInterval()); RV::enableErrorHandling(); if (PEAR::isError($result)) { $message = "\nThe operation interval in your OpenX configuration file is not valid. Please see the OpenX\ndocumentation for more details on valid operation interval values.\n"; echo $message; echo $haltMessage; exit; } $oStartDate = new Date(INTERVAL_START); $result = OX_OperationInterval::checkDateIsStartDate($oStartDate); if (!$result) { $message = "\nThe start date defined in the {$scriptName} script is not a valid operation interval start date.\nPlease edit the statisticsTestAndCorrect.php script before running.\n"; echo $message; echo $haltMessage; exit; } $oEndDate = new Date(INTERVAL_END); $result = OX_OperationInterval::checkDateIsEndDate($oEndDate); if (!$result) { $message = "\nThe end date defined in the {$scriptName} script is not a valid operation interval start date.\nPlease edit the statisticsTestAndCorrect.php script before running.\n"; echo $message; echo $haltMessage; exit; } $oMigrateBucketData = new OX_Maintenance_Statistics_MigrateBucketData();