From 89b2fc2accc813a753a31c5d5d730f97a5b06706 Mon Sep 17 00:00:00 2001 From: Frédéric Buclin Date: Sat, 14 Apr 2012 19:45:05 +0200 Subject: Bug 616192: Display personal tags in buglists r=timello a=LpSolit --- Bugzilla/Field.pm | 2 +- Bugzilla/Search.pm | 143 ++++++++++++++++++++++++++++++----------------------- 2 files changed, 82 insertions(+), 63 deletions(-) (limited to 'Bugzilla') diff --git a/Bugzilla/Field.pm b/Bugzilla/Field.pm index 12ef0c54f..4ec592164 100644 --- a/Bugzilla/Field.pm +++ b/Bugzilla/Field.pm @@ -248,7 +248,7 @@ use constant DEFAULT_FIELDS => ( {name => "owner_idle_time", desc => "Time Since Assignee Touched"}, {name => 'see_also', desc => "See Also", type => FIELD_TYPE_BUG_URLS}, - {name => 'tag', desc => 'Tags'}, + {name => 'tag', desc => 'Tags', buglist => 1}, ); ################ diff --git a/Bugzilla/Search.pm b/Bugzilla/Search.pm index 5c1a8c7ba..7f9bec9de 100644 --- a/Bugzilla/Search.pm +++ b/Bugzilla/Search.pm @@ -397,71 +397,88 @@ use constant COLUMN_DEPENDS => { # certain columns in the buglist. For the most part, Search.pm uses # DB::Schema to figure out what needs to be joined, but for some # fields it needs a little help. -use constant COLUMN_JOINS => { - actual_time => { - table => '(SELECT bug_id, SUM(work_time) AS total' - . ' FROM longdescs GROUP BY bug_id)', - join => 'INNER', - }, - assigned_to => { - from => 'assigned_to', - to => 'userid', - table => 'profiles', - join => 'INNER', - }, - reporter => { - from => 'reporter', - to => 'userid', - table => 'profiles', - join => 'INNER', - }, - qa_contact => { - from => 'qa_contact', - to => 'userid', - table => 'profiles', - }, - component => { - from => 'component_id', - to => 'id', - table => 'components', - join => 'INNER', - }, - product => { - from => 'product_id', - to => 'id', - table => 'products', - join => 'INNER', - }, - classification => { - table => 'classifications', - from => 'map_product.classification_id', - to => 'id', - join => 'INNER', - }, - 'flagtypes.name' => { - as => 'map_flags', - table => 'flags', - extra => ['map_flags.attach_id IS NULL'], - then_to => { - as => 'map_flagtypes', - table => 'flagtypes', - from => 'map_flags.type_id', +sub COLUMN_JOINS { + my $invocant = shift; + my $user = blessed($invocant) ? $invocant->_user : Bugzilla->user; + + my $joins = { + actual_time => { + table => '(SELECT bug_id, SUM(work_time) AS total' + . ' FROM longdescs GROUP BY bug_id)', + join => 'INNER', + }, + assigned_to => { + from => 'assigned_to', + to => 'userid', + table => 'profiles', + join => 'INNER', + }, + reporter => { + from => 'reporter', + to => 'userid', + table => 'profiles', + join => 'INNER', + }, + qa_contact => { + from => 'qa_contact', + to => 'userid', + table => 'profiles', + }, + component => { + from => 'component_id', to => 'id', + table => 'components', + join => 'INNER', }, - }, - keywords => { - table => 'keywords', - then_to => { - as => 'map_keyworddefs', - table => 'keyworddefs', - from => 'map_keywords.keywordid', + product => { + from => 'product_id', to => 'id', + table => 'products', + join => 'INNER', }, - }, - 'longdescs.count' => { - table => 'longdescs', - join => 'INNER', - }, + classification => { + table => 'classifications', + from => 'map_product.classification_id', + to => 'id', + join => 'INNER', + }, + 'flagtypes.name' => { + as => 'map_flags', + table => 'flags', + extra => ['map_flags.attach_id IS NULL'], + then_to => { + as => 'map_flagtypes', + table => 'flagtypes', + from => 'map_flags.type_id', + to => 'id', + }, + }, + keywords => { + table => 'keywords', + then_to => { + as => 'map_keyworddefs', + table => 'keyworddefs', + from => 'map_keywords.keywordid', + to => 'id', + }, + }, + 'longdescs.count' => { + table => 'longdescs', + join => 'INNER', + }, + tag => { + as => 'map_bug_tag', + table => 'bug_tag', + then_to => { + as => 'map_tag', + table => 'tag', + extra => ['map_tag.user_id = ' . $user->id], + from => 'map_bug_tag.tag_id', + to => 'id', + }, + } + }; + return $joins; }; # This constant defines the columns that can be selected in a query @@ -527,6 +544,8 @@ sub COLUMNS { 'keywords' => $dbh->sql_group_concat('DISTINCT map_keyworddefs.name'), 'longdescs.count' => 'COUNT(DISTINCT map_longdescs_count.comment_id)', + + tag => $dbh->sql_group_concat($dbh->sql_string_concat('map_tag.name')), ); # Backward-compatibility for old field names. Goes new_name => old_name. @@ -1816,7 +1835,7 @@ sub _get_column_joins { return $cache->{column_joins} if defined $cache->{column_joins}; - my %column_joins = %{ COLUMN_JOINS() }; + my %column_joins = %{ $self->COLUMN_JOINS() }; Bugzilla::Hook::process('buglist_column_joins', { column_joins => \%column_joins }); -- cgit v1.2.3-24-g4f1b