From 8fa9965e5476717e574f2674c6df8c4487874634 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Buclin?= Date: Sun, 30 Jan 2011 13:07:59 +0100 Subject: Bug 616185: Move tags (aka lists of bugs) to their own DB tables r/a=mkanat --- Bugzilla/User.pm | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'Bugzilla/User.pm') diff --git a/Bugzilla/User.pm b/Bugzilla/User.pm index eafda6563..0b639ee0d 100644 --- a/Bugzilla/User.pm +++ b/Bugzilla/User.pm @@ -363,6 +363,24 @@ sub queries_available { return $self->{queries_available}; } +sub tags { + my $self = shift; + my $dbh = Bugzilla->dbh; + + if (!defined $self->{tags}) { + # We must use LEFT JOIN instead of INNER JOIN as we may be + # in the process of inserting a new tag to some bugs, + # in which case there are no bugs with this tag yet. + $self->{tags} = $dbh->selectall_hashref( + 'SELECT name, id, COUNT(bug_id) AS bug_count + FROM tags + LEFT JOIN bug_tag ON bug_tag.tag_id = tags.id + WHERE user_id = ? ' . $dbh->sql_group_by('id', 'name'), + 'name', undef, $self->id); + } + return $self->{tags}; +} + ########################## # Saved Recent Bug Lists # ########################## @@ -2074,6 +2092,11 @@ internally, such code must call this method to flush the cached result. An arrayref of group ids. The user can share their own queries with these groups. +=item C + +Returns a hashref with tag IDs as key, and a hashref with tag 'id', +'name' and 'bug_count' as value. + =back =head2 Account Lockout -- cgit v1.2.1