From: Nik Okuntseff Date: Sun, 12 Jun 2016 16:49:09 +0000 (+0000) Subject: Added a separate databa cleanup script. X-Git-Tag: timetracker_1.19-1~1709 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=2b720c4a817350814e5e6bc440e500a669116d28;p=timetracker.git Added a separate databa cleanup script. --- diff --git a/WEB-INF/lib/ttTeamHelper.class.php b/WEB-INF/lib/ttTeamHelper.class.php index ed4c5195..e76482d0 100644 --- a/WEB-INF/lib/ttTeamHelper.class.php +++ b/WEB-INF/lib/ttTeamHelper.class.php @@ -758,7 +758,7 @@ class ttTeamHelper { $count++; $inactive_teams[] = $team_id; // Limit the array size for perfomance by allowing this operation on small chunks only. - if ($count >= 25) break; + if ($count >= 100) break; } } return $inactive_teams; diff --git a/cron_db_cleanup.php b/cron_db_cleanup.php new file mode 100644 index 00000000..5e1f259c --- /dev/null +++ b/cron_db_cleanup.php @@ -0,0 +1,66 @@ +\n"; +for ($i = 0; $i < $count; $i++) { + print " deleting team ".$inactive_teams[$i]."
\n"; + $res = ttTeamHelper::delete($inactive_teams[$i]); +} + +$mdb2 = getConnection(); +$mdb2->exec("OPTIMIZE TABLE tt_client_project_binds"); +$mdb2->exec("OPTIMIZE TABLE tt_client_project_binds"); +$mdb2->exec("OPTIMIZE TABLE tt_clients"); +$mdb2->exec("OPTIMIZE TABLE tt_config"); +$mdb2->exec("OPTIMIZE TABLE tt_custom_field_log"); +$mdb2->exec("OPTIMIZE TABLE tt_custom_field_options"); +$mdb2->exec("OPTIMIZE TABLE tt_custom_fields"); +$mdb2->exec("OPTIMIZE TABLE tt_expense_items"); +$mdb2->exec("OPTIMIZE TABLE tt_fav_reports"); +$mdb2->exec("OPTIMIZE TABLE tt_invoices"); +$mdb2->exec("OPTIMIZE TABLE tt_log"); +$mdb2->exec("OPTIMIZE TABLE tt_project_task_binds"); +$mdb2->exec("OPTIMIZE TABLE tt_projects"); +$mdb2->exec("OPTIMIZE TABLE tt_tasks"); +$mdb2->exec("OPTIMIZE TABLE tt_teams"); +$mdb2->exec("OPTIMIZE TABLE tt_tmp_refs"); +$mdb2->exec("OPTIMIZE TABLE tt_user_project_binds"); +$mdb2->exec("OPTIMIZE TABLE tt_users"); + +print "Done!
\n";