summaryrefslogtreecommitdiffstats
path: root/extensions/UserProfile/bin
diff options
context:
space:
mode:
authorByron Jones <bjones@mozilla.com>2013-09-11 08:28:31 +0200
committerByron Jones <bjones@mozilla.com>2013-09-11 08:28:31 +0200
commit2e44ee8fbe496a192099ba894df9dabd1b4fd6a7 (patch)
tree5f3b1897905677dadfd9316bd97154feff8aba57 /extensions/UserProfile/bin
parent4b5d2d61669c35919345dc27e0ed3831ada92f24 (diff)
downloadbugzilla-2e44ee8fbe496a192099ba894df9dabd1b4fd6a7.tar.gz
bugzilla-2e44ee8fbe496a192099ba894df9dabd1b4fd6a7.tar.xz
Bug 912564: tbpl gets deadlocks setting last_activity_ts
Diffstat (limited to 'extensions/UserProfile/bin')
-rwxr-xr-xextensions/UserProfile/bin/update.pl50
1 files changed, 47 insertions, 3 deletions
diff --git a/extensions/UserProfile/bin/update.pl b/extensions/UserProfile/bin/update.pl
index 4cdb08fe7..457585f8d 100755
--- a/extensions/UserProfile/bin/update.pl
+++ b/extensions/UserProfile/bin/update.pl
@@ -18,10 +18,45 @@ BEGIN { Bugzilla->extensions() }
use Bugzilla::Constants;
use Bugzilla::Extension::UserProfile::Util;
+use Bugzilla::User;
Bugzilla->usage_mode(USAGE_MODE_CMDLINE);
+my $dbh = Bugzilla->dbh;
+my $user_ids;
+my $verbose = grep { $_ eq '-v' } @ARGV;
-my $user_ids = Bugzilla->dbh->selectcol_arrayref(
+$user_ids = $dbh->selectcol_arrayref(
+ "SELECT user_id
+ FROM profiles_statistics_recalc
+ ORDER BY user_id",
+ { Slice => {} }
+);
+
+if (@$user_ids) {
+ print "recalculating last_user_activity\n";
+ my ($count, $total) = (0, scalar(@$user_ids));
+ foreach my $user_id (@$user_ids) {
+ if ($verbose) {
+ $count++;
+ my $login = user_id_to_login($user_id);
+ print "$count/$total $login ($user_id)\n";
+ }
+ $dbh->do(
+ "UPDATE profiles
+ SET last_activity_ts = ?,
+ last_statistics_ts = NULL
+ WHERE userid = ?",
+ undef,
+ last_user_activity($user_id),
+ $user_id
+ );
+ }
+ $dbh->do(
+ "DELETE FROM profiles_statistics_recalc WHERE " . $dbh->sql_in('user_id', $user_ids)
+ );
+}
+
+$user_ids = $dbh->selectcol_arrayref(
"SELECT userid
FROM profiles
WHERE last_activity_ts IS NOT NULL
@@ -31,6 +66,15 @@ my $user_ids = Bugzilla->dbh->selectcol_arrayref(
{ Slice => {} }
);
-foreach my $user_id (@$user_ids) {
- update_statistics_by_user($user_id);
+if (@$user_ids) {
+ $verbose && print "updating statistics\n";
+ my ($count, $total) = (0, scalar(@$user_ids));
+ foreach my $user_id (@$user_ids) {
+ if ($verbose) {
+ $count++;
+ my $login = user_id_to_login($user_id);
+ print "$count/$total $login ($user_id)\n";
+ }
+ update_statistics_by_user($user_id);
+ }
}