summaryrefslogtreecommitdiffstats
path: root/Bugzilla
diff options
context:
space:
mode:
authorByron Jones <bjones@mozilla.com>2012-01-24 08:13:22 +0100
committerByron Jones <bjones@mozilla.com>2012-01-24 08:13:22 +0100
commit0284798a8cc4987c84805634a7a84d5d853a2168 (patch)
treec81fd47c1fadd9abb335c618959ac227107efb8e /Bugzilla
parent96624a115fe60b8ebdbbecbc2b38a7566d4e4c59 (diff)
downloadbugzilla-0284798a8cc4987c84805634a7a84d5d853a2168.tar.gz
bugzilla-0284798a8cc4987c84805634a7a84d5d853a2168.tar.xz
Bug 240437: Add a "last seen date" column to the profiles table
r=LpSolit, a=LpSolit
Diffstat (limited to 'Bugzilla')
-rw-r--r--Bugzilla/DB/Schema.pm1
-rw-r--r--Bugzilla/Install/DB.pm3
-rw-r--r--Bugzilla/User.pm43
3 files changed, 37 insertions, 10 deletions
diff --git a/Bugzilla/DB/Schema.pm b/Bugzilla/DB/Schema.pm
index eda4653e7..436258122 100644
--- a/Bugzilla/DB/Schema.pm
+++ b/Bugzilla/DB/Schema.pm
@@ -869,6 +869,7 @@ use constant ABSTRACT_SCHEMA => {
extern_id => {TYPE => 'varchar(64)'},
is_enabled => {TYPE => 'BOOLEAN', NOTNULL => 1,
DEFAULT => 'TRUE'},
+ last_seen_date => {TYPE => 'DATETIME'},
],
INDEXES => [
profiles_login_name_idx => {FIELDS => ['login_name'],
diff --git a/Bugzilla/Install/DB.pm b/Bugzilla/Install/DB.pm
index 771d7e4f2..b9460cc31 100644
--- a/Bugzilla/Install/DB.pm
+++ b/Bugzilla/Install/DB.pm
@@ -647,6 +647,9 @@ sub update_table_definitions {
# 2011-06-15 dkl@mozilla.com - Bug 658929
_migrate_disabledtext_boolean();
+ # 2011-11-01 glob@mozilla.com - Bug 240437
+ $dbh->bz_add_column('profiles', 'last_seen_date', {TYPE => 'DATETIME'});
+
# 2011-10-11 miketosh - Bug 690173
_on_delete_set_null_for_audit_log_userid();
diff --git a/Bugzilla/User.pm b/Bugzilla/User.pm
index 23b08c63a..93142b3b7 100644
--- a/Bugzilla/User.pm
+++ b/Bugzilla/User.pm
@@ -65,16 +65,21 @@ use constant DB_TABLE => 'profiles';
# that you passed in for "name" to new(). That's because historically
# Bugzilla::User used "name" for the realname field. This should be
# fixed one day.
-use constant DB_COLUMNS => (
- 'profiles.userid',
- 'profiles.login_name',
- 'profiles.realname',
- 'profiles.mybugslink AS showmybugslink',
- 'profiles.disabledtext',
- 'profiles.disable_mail',
- 'profiles.extern_id',
- 'profiles.is_enabled',
-);
+sub DB_COLUMNS {
+ my $dbh = Bugzilla->dbh;
+ return (
+ 'profiles.userid',
+ 'profiles.login_name',
+ 'profiles.realname',
+ 'profiles.mybugslink AS showmybugslink',
+ 'profiles.disabledtext',
+ 'profiles.disable_mail',
+ 'profiles.extern_id',
+ 'profiles.is_enabled',
+ $dbh->sql_date_format('last_seen_date', '%Y-%m-%d') . ' AS last_seen_date',
+ ),
+}
+
use constant NAME_FIELD => 'login_name';
use constant ID_FIELD => 'userid';
use constant LIST_ORDER => NAME_FIELD;
@@ -258,6 +263,23 @@ sub set_disabledtext {
$_[0]->set('is_enabled', $_[1] ? 0 : 1);
}
+sub update_last_seen_date {
+ my $self = shift;
+ return unless $self->id;
+ my $dbh = Bugzilla->dbh;
+ my $date = $dbh->selectrow_array(
+ 'SELECT ' . $dbh->sql_date_format('NOW()', '%Y-%m-%d'));
+
+ if (!$self->last_seen_date or $date ne $self->last_seen_date) {
+ $self->{last_seen_date} = $date;
+ # We don't use the normal update() routine here as we only
+ # want to update the last_seen_date column, not any other
+ # pending changes
+ $dbh->do("UPDATE profiles SET last_seen_date = ? WHERE userid = ?",
+ undef, $date, $self->id);
+ }
+}
+
################################################################################
# Methods
################################################################################
@@ -272,6 +294,7 @@ sub is_enabled { $_[0]->{'is_enabled'} ? 1 : 0; }
sub showmybugslink { $_[0]->{showmybugslink}; }
sub email_disabled { $_[0]->{disable_mail}; }
sub email_enabled { !($_[0]->{disable_mail}); }
+sub last_seen_date { $_[0]->{last_seen_date}; }
sub cryptpassword {
my $self = shift;
# We don't store it because we never want it in the object (we