X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;ds=sidebyside;f=bin%2Fcron%2Fcompliance.php;h=d8e3ae49182c24a55f729c4b93beeb4a923f33d5;hb=6e1128e02f7568a692d548d8bc43cad6bde38efe;hp=0a07a15325ccfe21a51298c8df638a1227904c0d;hpb=1dc71da137a384e771723b8a893539a7f5cc9fab;p=platal.git diff --git a/bin/cron/compliance.php b/bin/cron/compliance.php index 0a07a15..d8e3ae4 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 logger.sessions AS s - LEFT JOIN x4dat.auth_user_md5 AS u ON (u.user_id = s.uid) - WHERE u.user_id IS NULL"); + 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"; } } @@ -69,13 +110,15 @@ function checkOrphanedSessions() { * Purges session events without a valid session. */ function purgeOrphanedEvents() { + $begin = time(); XDB::execute( - "DELETE logger.e - FROM logger.events AS e - LEFT JOIN logger.sessions AS s ON (s.id = e.session) + "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. @@ -93,8 +136,8 @@ checkOrphanedSessions(); purgeOrphanedEvents(); // Many rows have been removed from the two logger tables. Let's optimize them. -XDB::execute("OPTIMIZE TABLE logger.events"); -XDB::execute("OPTIMIZE TABLE logger.sessions"); +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: ?>