diff options
author | Evan Prodromou <evan@status.net> | 2009-12-31 09:14:55 -1000 |
---|---|---|
committer | Evan Prodromou <evan@status.net> | 2009-12-31 09:14:55 -1000 |
commit | 053b8c600d7db73ec19e5f1d3e26c4c98fdf3d8c (patch) | |
tree | 5664c78f951e91827c810b745a771aeb21ab9dbf /scripts | |
parent | ad8ea98cd72855f61c71945b533331b6f30d04b6 (diff) | |
parent | 01dbee2ba5280d97ddd0bb82217e8b3e7680e67b (diff) |
Merge branch '0.9.x' of git@gitorious.org:statusnet/mainline into 0.9.x
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/triminboxes.php | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/scripts/triminboxes.php b/scripts/triminboxes.php index da09817e5..ea4751305 100644 --- a/scripts/triminboxes.php +++ b/scripts/triminboxes.php @@ -21,19 +21,21 @@ define('INSTALLDIR', realpath(dirname(__FILE__) . '/..')); $shortoptions = 'u::'; -$longoptions = array('start-user-id::'); +$longoptions = array('start-user-id=', 'sleep-time='); $helptext = <<<END_OF_TRIM_HELP Batch script for trimming notice inboxes to a reasonable size. -u <id> --start-user-id=<id> User ID to start after. Default is all. + --sleep-time=<integer> Amount of time to wait (in seconds) between trims. Default is zero. END_OF_TRIM_HELP; require_once INSTALLDIR.'/scripts/commandline.inc'; $id = null; +$sleep_time = 0; if (have_option('u')) { $id = get_option_value('u'); @@ -43,6 +45,12 @@ if (have_option('u')) { $id = null; } +if (have_option('--sleep-time')) { + $sleep_time = intval(get_option_value('--sleep-time')); +} + +$quiet = have_option('q') || have_option('--quiet'); + $user = new User(); if (!empty($id)) { @@ -52,5 +60,17 @@ if (!empty($id)) { $cnt = $user->find(); while ($user->fetch()) { - Notice_inbox::gc($user->id); + if (!$quiet) { + print "Trimming inbox for user $user->id"; + } + $count = Notice_inbox::gc($user->id); + if ($count) { + if (!$quiet) { + print ": $count trimmed..."; + } + sleep($sleep_time); + } + if (!$quiet) { + print "\n"; + } } |