Skip to content
This repository has been archived by the owner on Jan 20, 2024. It is now read-only.

Commit

Permalink
Added timing check to janitor hook to prevent unnecessary http calls …
Browse files Browse the repository at this point in the history
…to janitorial services.
  • Loading branch information
michaelchisari authored and The Appleseed Project committed Jan 26, 2011
1 parent cb16369 commit 71c2dd1
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions hooks/janitor/janitor.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,24 @@ public function __construct ( ) {
}

public function EndFooterDisplay ( $pData = null ) {

$Model = new cModel('Janitor');

$Model->Retrieve();

$Model->Fetch();

$lastUpdated = strtotime ( $Model->Get ( 'Updated' ) );
$now = strtotime ( NOW() );

$diff = $now - $lastUpdated;
$diffMinutes = $diff / 60;

// If we've recently updated, don't ping the Janitor.
if ( $diffMinutes < 1 ) return ( true );

$this->_Janitorial();

return ( true );
}

Expand Down

0 comments on commit 71c2dd1

Please sign in to comment.