/** * A private method that determines which (if any) operation intervals need the zone * impression forecast values to be updated for ALL zones. * * @access private * @return mixed One of the following three values will be returned, depending on what * ZIF values need to be updated: * - true: Update the ZIF values for all operation intervals. * - false: No ZIF values need to be updated (eg. this is the second, or greater, * time that the MPE has been run in this operation interval, so there * are no new statistics values summarised by the MSE to allow the ZIF * values to be udpated). * - array: An array with the start and end operation interval IDs of the * range to update; the first may be higher than the second, in * the event that the range spans from the end of one week into the * start of the next week. */ function _getUpdateTypeRequired() { OA::debug('- Calculating range of operation intervals which require ZIF update', PEAR_LOG_DEBUG); // Set default return value $return = false; if (is_null($this->oStatisticsUpdatedToDate)) { // The MSE has never been run; there are no stats. Update all operation intervals (with the // default zone forecast value) so that this new installation of OpenX can ran: return true OA::debug(' - No previous maintenance statisitcs run, so update all OIs required', PEAR_LOG_DEBUG); $return = true; } elseif (is_null($this->oPriorityUpdatedToDate)) { // The MPE has never updated zone forecasts before. Update all operation intervals (with the // default zone forecast value) so that this new installation of OpenX can ran: return true OA::debug(' - No previous maintenance priority run, so update all OIs required', PEAR_LOG_DEBUG); $return = true; } elseif (OX_OperationInterval::getOperationInterval() != $this->priorityOperationInterval) { // The operation interval has changed since the last run, force an update all: return true OA::debug(' - OPERATION INTERVAL LENGTH CHANGE SINCE LAST RUN', PEAR_LOG_DEBUG); OA::debug(' - Update of all OIs required', PEAR_LOG_DEBUG); $return = true; } else { // If stats was run after priority, then the maintenance stats updated to date will be equal to, // or after, the maintenance priority updated to date (as the maintenance priority updated to // date is one operation interval ahead of where statistics is) if ($this->oStatisticsUpdatedToDate->equals($this->oPriorityUpdatedToDate) || $this->oStatisticsUpdatedToDate->after($this->oPriorityUpdatedToDate)) { // If a week or more has passed since the last priority update, update all: return true $oSpan = new Date_Span(); $oUpdatedToDateCopy = new Date(); $oUpdatedToDateCopy->copy($this->oPriorityUpdatedToDate); $oDateNowCopy = new Date(); $oDateNowCopy->copy($this->oDateNow); $oSpan->setFromDateDiff($oUpdatedToDateCopy, $oDateNowCopy); if ($oSpan->day >= 7) { OA::debug(' - One week has passed since last run, so update all OIs required', PEAR_LOG_DEBUG); $return = true; } else { // Get the operation intervals for each run $statsOpIntId = OX_OperationInterval::convertDateToOperationIntervalID($this->oStatisticsUpdatedToDate); $priorityOpIntId = OX_OperationInterval::convertDateToOperationIntervalID($this->oPriorityUpdatedToDate); // Always predict one interval ahead of the statistics engine $statsOpIntId = OX_OperationInterval::nextOperationIntervalID($statsOpIntId); // As long as the operation intervals are not in the same interval, priority should be run if ($statsOpIntId != $priorityOpIntId) { OA::debug(' - Found OI range to update', PEAR_LOG_DEBUG); $return = array($priorityOpIntId, $statsOpIntId); } else { OA::debug(' - MPE has already run this operation interval, no ZIF update required', PEAR_LOG_DEBUG); $return = false; } } } } return $return; }