Bug 1143874: Improve load time of bug comments
r=dkl a=sgreen git-svn-id: svn://10.0.0.236/trunk@265906 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
parent
db25c03efc
commit
75d2a3f43e
@ -1 +1 @@
|
|||||||
9360
|
9361
|
||||||
@ -1 +1 @@
|
|||||||
0d95dec384fc94b6ebaa5158a579aa099574cd59
|
b1886835c81c014c1423fa2f2d83e157cbde1406
|
||||||
@ -38,9 +38,6 @@ sub relationships {
|
|||||||
return %relationships;
|
return %relationships;
|
||||||
}
|
}
|
||||||
|
|
||||||
# This is a bit of a hack, basically keeping the old system()
|
|
||||||
# cmd line interface. Should clean this up at some point.
|
|
||||||
#
|
|
||||||
# args: bug_id, and an optional hash ref which may have keys for:
|
# args: bug_id, and an optional hash ref which may have keys for:
|
||||||
# changer, owner, qa, reporter, cc
|
# changer, owner, qa, reporter, cc
|
||||||
# Optional hash contains values of people which will be forced to those
|
# Optional hash contains values of people which will be forced to those
|
||||||
@ -88,6 +85,8 @@ sub Send {
|
|||||||
@diffs = _get_new_bugmail_fields($bug);
|
@diffs = _get_new_bugmail_fields($bug);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
my $comments = [];
|
||||||
|
|
||||||
if ($params->{dep_only}) {
|
if ($params->{dep_only}) {
|
||||||
push(@diffs, { field_name => 'bug_status',
|
push(@diffs, { field_name => 'bug_status',
|
||||||
old => $params->{changes}->{bug_status}->[0],
|
old => $params->{changes}->{bug_status}->[0],
|
||||||
@ -104,15 +103,15 @@ sub Send {
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
push(@diffs, _get_diffs($bug, $end, \%user_cache));
|
push(@diffs, _get_diffs($bug, $end, \%user_cache));
|
||||||
|
|
||||||
|
$comments = $bug->comments({ after => $start, to => $end });
|
||||||
|
# Skip empty comments.
|
||||||
|
@$comments = grep { $_->type || $_->body =~ /\S/ } @$comments;
|
||||||
|
|
||||||
|
# If no changes have been made, there is no need to process further.
|
||||||
|
return {'sent' => []} unless scalar(@diffs) || scalar(@$comments);
|
||||||
}
|
}
|
||||||
|
|
||||||
my $comments = $bug->comments({ after => $start, to => $end });
|
|
||||||
# Skip empty comments.
|
|
||||||
@$comments = grep { $_->type || $_->body =~ /\S/ } @$comments;
|
|
||||||
|
|
||||||
# If no changes have been made, there is no need to process further.
|
|
||||||
return {'sent' => []} unless scalar(@diffs) || scalar(@$comments);
|
|
||||||
|
|
||||||
###########################################################################
|
###########################################################################
|
||||||
# Start of email filtering code
|
# Start of email filtering code
|
||||||
###########################################################################
|
###########################################################################
|
||||||
|
|||||||
@ -162,11 +162,15 @@ sub preload {
|
|||||||
my $rows = $dbh->selectall_arrayref(
|
my $rows = $dbh->selectall_arrayref(
|
||||||
"SELECT comment_id, " . $dbh->sql_group_concat('tag', "','") . "
|
"SELECT comment_id, " . $dbh->sql_group_concat('tag', "','") . "
|
||||||
FROM longdescs_tags
|
FROM longdescs_tags
|
||||||
WHERE " . $dbh->sql_in('comment_id', \@comment_ids) . "
|
WHERE " . $dbh->sql_in('comment_id', \@comment_ids) . ' ' .
|
||||||
GROUP BY comment_id");
|
$dbh->sql_group_by('comment_id'));
|
||||||
foreach my $row (@$rows) {
|
foreach my $row (@$rows) {
|
||||||
$comment_map{$row->[0]}->{tags} = [ split(/,/, $row->[1]) ];
|
$comment_map{$row->[0]}->{tags} = [ split(/,/, $row->[1]) ];
|
||||||
}
|
}
|
||||||
|
# Also sets the 'tags' attribute for comments which have no entry
|
||||||
|
# in the longdescs_tags table, else calling $comment->tags will
|
||||||
|
# trigger another SQL query again.
|
||||||
|
$comment_map{$_}->{tags} ||= [] foreach @comment_ids;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -190,7 +194,8 @@ sub extra_data { return $_[0]->{'extra_data'} }
|
|||||||
|
|
||||||
sub tags {
|
sub tags {
|
||||||
my ($self) = @_;
|
my ($self) = @_;
|
||||||
return [] unless Bugzilla->params->{'comment_taggers_group'};
|
state $comment_taggers_group = Bugzilla->params->{'comment_taggers_group'};
|
||||||
|
return [] unless $comment_taggers_group;
|
||||||
$self->{'tags'} ||= Bugzilla->dbh->selectcol_arrayref(
|
$self->{'tags'} ||= Bugzilla->dbh->selectcol_arrayref(
|
||||||
"SELECT tag
|
"SELECT tag
|
||||||
FROM longdescs_tags
|
FROM longdescs_tags
|
||||||
@ -202,11 +207,14 @@ sub tags {
|
|||||||
|
|
||||||
sub collapsed {
|
sub collapsed {
|
||||||
my ($self) = @_;
|
my ($self) = @_;
|
||||||
return 0 unless Bugzilla->params->{'comment_taggers_group'};
|
state $comment_taggers_group = Bugzilla->params->{'comment_taggers_group'};
|
||||||
|
return 0 unless $comment_taggers_group;
|
||||||
return $self->{collapsed} if exists $self->{collapsed};
|
return $self->{collapsed} if exists $self->{collapsed};
|
||||||
|
|
||||||
|
state $collapsed_comment_tags = Bugzilla->params->{'collapsed_comment_tags'};
|
||||||
$self->{collapsed} = 0;
|
$self->{collapsed} = 0;
|
||||||
Bugzilla->request_cache->{comment_tags_collapsed}
|
Bugzilla->request_cache->{comment_tags_collapsed}
|
||||||
||= [ split(/\s*,\s*/, Bugzilla->params->{'collapsed_comment_tags'}) ];
|
||= [ split(/\s*,\s*/, $collapsed_comment_tags) ];
|
||||||
my @collapsed_tags = @{ Bugzilla->request_cache->{comment_tags_collapsed} };
|
my @collapsed_tags = @{ Bugzilla->request_cache->{comment_tags_collapsed} };
|
||||||
foreach my $my_tag (@{ $self->tags }) {
|
foreach my $my_tag (@{ $self->tags }) {
|
||||||
$my_tag = lc($my_tag);
|
$my_tag = lc($my_tag);
|
||||||
|
|||||||
@ -19,6 +19,7 @@
|
|||||||
[% DEFAULT mode = "show" %]
|
[% DEFAULT mode = "show" %]
|
||||||
[% user_cache = template_cache.users %]
|
[% user_cache = template_cache.users %]
|
||||||
[% markdown_enabled = feature_enabled('jsonrpc') AND user.settings.use_markdown.value == "on" %]
|
[% markdown_enabled = feature_enabled('jsonrpc') AND user.settings.use_markdown.value == "on" %]
|
||||||
|
[% can_edit_comments = bug.check_can_change_field('longdesc', 0, 1) %]
|
||||||
|
|
||||||
<!-- This auto-sizes the comments and positions the collapse/expand links
|
<!-- This auto-sizes the comments and positions the collapse/expand links
|
||||||
to the right. -->
|
to the right. -->
|
||||||
@ -26,9 +27,7 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
|
|
||||||
[% FOREACH comment = comments %]
|
[% PROCESS display_comments %]
|
||||||
[% PROCESS a_comment %]
|
|
||||||
[% END %]
|
|
||||||
|
|
||||||
[% IF mode == "edit" && user.id
|
[% IF mode == "edit" && user.id
|
||||||
&& user.settings.comment_box_position.value == "before_comments" %]
|
&& user.settings.comment_box_position.value == "before_comments" %]
|
||||||
@ -69,10 +68,11 @@
|
|||||||
[%# Block for individual comments #%]
|
[%# Block for individual comments #%]
|
||||||
[%############################################################################%]
|
[%############################################################################%]
|
||||||
|
|
||||||
[% BLOCK a_comment %]
|
[% BLOCK display_comments %]
|
||||||
[% RETURN IF comment.is_private AND NOT (user.is_insider || user.id == comment.author.id) %]
|
[% FOREACH comment = comments %]
|
||||||
[% comment_text = comment.body_full %]
|
[% NEXT IF comment.is_private AND NOT (user.is_insider || user.id == comment.author.id) %]
|
||||||
[% RETURN IF comment_text == '' AND (comment.work_time - 0) != 0 AND !user.is_timetracker %]
|
[% comment_text = comment.body_full %]
|
||||||
|
[% NEXT IF comment_text == '' AND (comment.work_time - 0) != 0 AND !user.is_timetracker %]
|
||||||
|
|
||||||
<div id="c[% comment.count %]" class="bz_comment[% " bz_private" IF comment.is_private %]
|
<div id="c[% comment.count %]" class="bz_comment[% " bz_private" IF comment.is_private %]
|
||||||
[% " bz_default_collapsed" IF comment.collapsed %]
|
[% " bz_default_collapsed" IF comment.collapsed %]
|
||||||
@ -92,7 +92,7 @@
|
|||||||
[% IF comment.collapsed %]
|
[% IF comment.collapsed %]
|
||||||
<span class="bz_collapsed_actions">
|
<span class="bz_collapsed_actions">
|
||||||
[% END %]
|
[% END %]
|
||||||
[% IF bug.check_can_change_field('longdesc', 0, 1) %]
|
[% IF can_edit_comments %]
|
||||||
[% IF user.can_tag_comments %]
|
[% IF user.can_tag_comments %]
|
||||||
[<a href="#"
|
[<a href="#"
|
||||||
onclick="YAHOO.bugzilla.commentTagging.toggle([% comment.id %], [% comment.count %]);return false">tag</a>]
|
onclick="YAHOO.bugzilla.commentTagging.toggle([% comment.id %], [% comment.count %]);return false">tag</a>]
|
||||||
@ -125,7 +125,7 @@
|
|||||||
</span>
|
</span>
|
||||||
[% END %]
|
[% END %]
|
||||||
|
|
||||||
[% IF mode == "edit" && user.is_insider && bug.check_can_change_field('longdesc', 0, 1) %]
|
[% IF mode == "edit" && can_edit_comments && user.is_insider %]
|
||||||
<div class="bz_private_checkbox">
|
<div class="bz_private_checkbox">
|
||||||
<input type="hidden" value="1"
|
<input type="hidden" value="1"
|
||||||
name="defined_isprivate_[% comment.id %]">
|
name="defined_isprivate_[% comment.id %]">
|
||||||
@ -214,4 +214,5 @@
|
|||||||
</[% user.use_markdown(comment) ? "div" : "pre" %]>
|
</[% user.use_markdown(comment) ? "div" : "pre" %]>
|
||||||
[% Hook.process('a_comment-end', 'bug/comments.html.tmpl') %]
|
[% Hook.process('a_comment-end', 'bug/comments.html.tmpl') %]
|
||||||
</div>
|
</div>
|
||||||
|
[% END %]
|
||||||
[% END %]
|
[% END %]
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user