summaryrefslogtreecommitdiffstats
path: root/clean-bug-user-last-visit.pl
diff options
context:
space:
mode:
authorDylan William Hardison [:dylan] <dylan@mozilla.com>2014-06-03 09:57:28 +0200
committerByron Jones <glob@mozilla.com>2014-06-03 09:57:28 +0200
commit1fbae4ef5a9cca5d889a6fed3b930c1c9d641d6e (patch)
tree7145c2d59544d11556cf1817227e7c725d22be10 /clean-bug-user-last-visit.pl
parentc725b6c20ae8157a3a13674755b2de5148a1fe26 (diff)
downloadbugzilla-1fbae4ef5a9cca5d889a6fed3b930c1c9d641d6e.tar.gz
bugzilla-1fbae4ef5a9cca5d889a6fed3b930c1c9d641d6e.tar.xz
Bug 1000917: Backport upstream bug 489028 to bmo/4.2 to allow user last visit searching
Diffstat (limited to 'clean-bug-user-last-visit.pl')
-rw-r--r--clean-bug-user-last-visit.pl38
1 files changed, 38 insertions, 0 deletions
diff --git a/clean-bug-user-last-visit.pl b/clean-bug-user-last-visit.pl
new file mode 100644
index 000000000..9884b7c48
--- /dev/null
+++ b/clean-bug-user-last-visit.pl
@@ -0,0 +1,38 @@
+#!/usr/bin/perl -wT
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+# This Source Code Form is "Incompatible With Secondary Licenses", as
+# defined by the Mozilla Public License, v. 2.0.
+
+=head1 NAME
+
+clean-bug-user-last-visit.pl
+
+=head1 DESCRIPTION
+
+This utility script cleans out entries from the bug_user_last_visit table that
+are older than (a configurable) number of days.
+
+It takes no arguments and produces no output except in the case of errors.
+
+=cut
+
+use 5.10.1;
+use strict;
+use warnings;
+use lib qw(. lib);
+
+use Bugzilla;
+use Bugzilla::Constants;
+
+Bugzilla->usage_mode(USAGE_MODE_CMDLINE);
+
+my $dbh = Bugzilla->dbh;
+my $sql = 'DELETE FROM bug_user_last_visit WHERE last_visit_ts < '
+ . $dbh->sql_date_math('NOW()',
+ '-',
+ Bugzilla->params->{last_visit_keep_days},
+ 'DAY');
+$dbh->do($sql);