X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=bin%2Fcron%2Fcompliance.php;h=fef927391626a6b4c4d646f16b5f55517227cfc8;hb=3424387cde6c635ff16c3b5459c4caa88bb76e2e;hp=3c3230598cf62d4be1b9615d90f847b7abe615b8;hpb=5b48ebf46ef939d701852d2117bbcf308036027c;p=platal.git diff --git a/bin/cron/compliance.php b/bin/cron/compliance.php index 3c32305..fef9273 100755 --- a/bin/cron/compliance.php +++ b/bin/cron/compliance.php @@ -1,7 +1,7 @@ #!/usr/bin/php5 -q = {?} AND a.uid < {?} + ORDER BY a.uid ASC) AS ut ON (ut.uid = s.uid) + WHERE s.start < DATE_SUB(NOW(), INTERVAL {?} MONTH) + AND s.start < ut.no_discard_limit", + $minimalBacklog - 1, $state, $isAdmin, $lowUID, $highUID, $retentionPeriod); + + $nbBatches += 1; + $affectedRows += XDB::affectedRows(); + } + + $duration = time() - $begin; + echo "Users with permission '$userPerms': removed $affectedRows sessions in $duration seconds ($nbBatches batches).\n"; } /** * Checks for sessions without a valid associated user id. */ function checkOrphanedSessions() { + $begin = time(); $res = XDB::query( "SELECT COUNT(*) FROM log_sessions AS s LEFT JOIN #x5dat#.accounts AS a ON (a.uid = s.uid) WHERE a.uid IS NULL"); if (($count = $res->fetchOneCell())) { - echo "Orphaned sessions: found $count orphaned sessions. Please fix that.\n"; + $duration = time() - $begin; + echo "Orphaned sessions: found $count orphaned sessions in $duration seconds. Please fix that.\n"; } } @@ -86,13 +110,15 @@ function checkOrphanedSessions() { * Purges session events without a valid session. */ function purgeOrphanedEvents() { + $begin = time(); XDB::execute( "DELETE e FROM log_events AS e LEFT JOIN log_sessions AS s ON (s.id = e.session) WHERE s.id IS NULL"); $affectedRows = XDB::affectedRows(); - echo "Orphaned events: removed $affectedRows events.\n"; + $duration = time() - $begin; + echo "Orphaned events: removed $affectedRows events in $duration seconds.\n"; } // Remove expired sessions. @@ -113,5 +139,5 @@ purgeOrphanedEvents(); XDB::execute("OPTIMIZE TABLE log_events"); XDB::execute("OPTIMIZE TABLE log_sessions"); -// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: +// vim:set et sw=4 sts=4 sws=4 foldmethod=marker fenc=utf-8: ?>