Move report generation logic to Bugzilla::Report, support reports in whines

i18n
Vitaliy Filippov 2016-08-02 18:27:07 +03:00
parent ad5c5b6814
commit a8e11f918e
15 changed files with 349 additions and 287 deletions

View File

@ -1132,6 +1132,7 @@ use constant ABSTRACT_SCHEMA => {
sortkey => {TYPE => 'INT4', NOTNULL => 1, DEFAULT => '0'},
onemailperbug => {TYPE => 'BOOLEAN', NOTNULL => 1, DEFAULT => 'FALSE'},
title => {TYPE => 'varchar(255)', NOTNULL => 1, DEFAULT => "''"},
isreport => {TYPE => 'BOOLEAN', NOTNULL => 1, DEFAULT => 'FALSE'},
],
INDEXES => [
whine_queries_eventid_idx => ['eventid'],

View File

@ -866,6 +866,8 @@ WHERE description LIKE \'%[CC:%]%\'');
$dbh->bz_add_column('checkers', 'bypass_group_id');
$dbh->bz_add_column('whine_queries', 'isreport');
_move_old_defaults($old_params);
################################################################

View File

@ -104,6 +104,263 @@ sub check
return $report;
}
sub _get_names
{
my ($names, $isnumeric, $field) = @_;
# These are all the fields we want to preserve the order of in reports.
my $f = $field && Bugzilla->get_field($field);
if ($f && $f->is_select)
{
my $values = [ '', map { $_->name } @{ $f->legal_values(1) } ];
my %dup;
@$values = grep { exists($names->{$_}) && !($dup{$_}++) } @$values;
return $values;
}
elsif ($isnumeric)
{
# It's not a field we are preserving the order of, so sort it
# numerically...
sub numerically { $a <=> $b }
return [ sort numerically keys %$names ];
}
else
{
# ...or alphabetically, as appropriate.
return [ sort keys %$names ];
}
}
sub execute
{
my $class = shift;
my ($ARGS, $runner) = @_;
my $valid_columns = Bugzilla::Search->REPORT_COLUMNS();
my $field = {};
for (qw(x y z))
{
my $f = $ARGS->{$_.'_axis_field'} || '';
trick_taint($f);
if ($f)
{
if ($valid_columns->{$f})
{
$field->{$_} = $f;
}
else
{
ThrowCodeError("report_axis_invalid", {fld => $_, val => $f});
}
}
}
if (!keys %$field)
{
ThrowUserError("no_axes_defined");
}
my $width = $ARGS->{width} || 600;
my $height = $ARGS->{height} || 350;
if (defined($width))
{
(detaint_natural($width) && $width > 0)
|| ThrowCodeError("invalid_dimensions");
$width <= 2000 || ThrowUserError("chart_too_large");
}
if (defined($height))
{
(detaint_natural($height) && $height > 0)
|| ThrowCodeError("invalid_dimensions");
$height <= 2000 || ThrowUserError("chart_too_large");
}
# These shenanigans are necessary to make sure that both vertical and
# horizontal 1D tables convert to the correct dimension when you ask to
# display them as some sort of chart.
my $is_table;
if ($ARGS->{format} eq 'table' || $ARGS->{format} eq 'simple')
{
$is_table = 1;
if ($field->{x} && !$field->{y})
{
# 1D *tables* should be displayed vertically (with a row_field only)
$field->{y} = $field->{x};
delete $field->{x};
}
}
else
{
if (!Bugzilla->feature('graphical_reports'))
{
ThrowCodeError('feature_disabled', { feature => 'graphical_reports' });
}
if ($field->{y} && !$field->{x})
{
# 1D *charts* should be displayed horizontally (with an col_field only)
$field->{x} = $field->{y};
delete $field->{y};
}
}
my $measures = {
etime => 'estimated_time',
rtime => 'remaining_time',
wtime => 'interval_time',
count => '_count',
};
# Trick Bugzilla::Search: replace report columns SQL + add '_count' column
# FIXME: Remove usage of global variable COLUMNS in search generation code
my %old_columns = %{Bugzilla::Search->COLUMNS($runner)};
%{Bugzilla::Search->COLUMNS($runner)} = (%{Bugzilla::Search->COLUMNS($runner)}, %{Bugzilla::Search->REPORT_COLUMNS});
Bugzilla::Search->COLUMNS($runner)->{_count}->{name} = '1';
my $measure = $ARGS->{measure} || '';
if ($measure eq 'times' ? !$is_table : !$measures->{$measure})
{
$measure = 'count';
}
# Validate the values in the axis fields or throw an error.
my %a;
my @group_by = grep { !($a{$_}++) } values %$field;
my @axis_fields = @group_by;
for ($measure eq 'times' ? qw(etime rtime wtime) : $measure)
{
push @axis_fields, $measures->{$_} unless $a{$measures->{$_}};
}
# Clone the params, so that Bugzilla::Search can modify them
my $search = new Bugzilla::Search(
fields => \@axis_fields,
params => { %$ARGS },
user => $runner,
);
my $query = $search->getSQL();
$query =
"SELECT ".
($field->{x} || "''")." x, ".
($field->{y} || "''")." y, ".
($field->{z} || "''")." z, ".
join(', ', map { "SUM($measures->{$_}) $_" } $measure eq 'times' ? qw(etime rtime wtime) : $measure).
" FROM ($query) _report_table GROUP BY ".join(", ", @group_by);
$::SIG{TERM} = 'DEFAULT';
$::SIG{PIPE} = 'DEFAULT';
my $results = Bugzilla->dbh->selectall_arrayref($query, {Slice=>{}});
# We have a hash of hashes for the data itself, and a hash to hold the
# row/col/table names.
my %data;
my %names;
# Read the bug data and count the bugs for each possible value of row, column
# and table.
#
# We detect a numerical field, and sort appropriately, if all the values are
# numeric.
my %isnumeric;
foreach my $group (@$results)
{
for (qw(x y z))
{
$isnumeric{$_} &&= ($group->{$_} =~ /^-?\d+(\.\d+)?$/o);
$names{$_}{$group->{$_}} = 1;
}
$data{$group->{z}}{$group->{x}}{$group->{y}} = $is_table ? $group : $group->{$measure};
}
my @tbl_names = @{_get_names($names{z}, $isnumeric{z}, $field->{z})};
my @col_names = @{_get_names($names{x}, $isnumeric{x}, $field->{x})};
my @row_names = @{_get_names($names{y}, $isnumeric{y}, $field->{y})};
# The GD::Graph package requires a particular format of data, so once we've
# gathered everything into the hashes and made sure we know the size of the
# data, we reformat it into an array of arrays of arrays of data.
push @tbl_names, "-total-" if scalar(@tbl_names) > 1;
my @image_data;
foreach my $tbl (@tbl_names)
{
my @tbl_data;
push @tbl_data, \@col_names;
foreach my $row (@row_names)
{
my @col_data;
foreach my $col (@col_names)
{
$data{$tbl}{$col}{$row} ||= {};
push @col_data, $data{$tbl}{$col}{$row};
if ($tbl ne "-total-")
{
# This is a bit sneaky. We spend every loop except the last
# building up the -total- data, and then last time round,
# we process it as another tbl, and push() the total values
# into the image_data array.
for my $m (keys %{$data{$tbl}{$col}{$row}})
{
next if $m eq 'x' || $m eq 'y' || $m eq 'z';
$data{"-total-"}{$col}{$row}{$m} += $data{$tbl}{$col}{$row}{$m};
}
}
}
push @tbl_data, \@col_data;
}
unshift @image_data, \@tbl_data;
}
# Below a certain width, we don't see any bars, so there needs to be a minimum.
if ($width && $ARGS->{format} eq "bar")
{
my $min_width = (scalar(@col_names) || 1) * 20;
if (!$ARGS->{cumulate})
{
$min_width *= (scalar(@row_names) || 1);
}
$width = $min_width;
}
my $vars = {};
$vars->{fields} = $field;
# for debugging
$vars->{query} = $query;
# We need to keep track of the defined restrictions on each of the
# axes, because buglistbase, below, throws them away. Without this, we
# get buglistlinks wrong if there is a restriction on an axis field.
$vars->{col_vals} = $field->{x} ? http_build_query({ $field->{x} => $ARGS->{$field->{x}} }) : '';
$vars->{row_vals} = $field->{y} ? http_build_query({ $field->{y} => $ARGS->{$field->{y}} }) : '';
$vars->{tbl_vals} = $field->{z} ? http_build_query({ $field->{z} => $ARGS->{$field->{z}} }) : '';
my $a = { %$ARGS };
delete $a->{$_} for qw(x_axis_field y_axis_field z_axis_field ctype format query_format measure), @axis_fields;
$vars->{buglistbase} = http_build_query($a);
$vars->{image_data} = \@image_data;
$vars->{data} = \%data;
$vars->{measure} = $measure;
$vars->{tbl_field} = $field->{z};
$vars->{col_field} = $field->{x};
$vars->{row_field} = $field->{y};
$vars->{col_names} = \@col_names;
$vars->{row_names} = \@row_names;
$vars->{tbl_names} = \@tbl_names;
$vars->{width} = $width;
$vars->{height} = $height;
$vars->{cumulate} = $ARGS->{cumulate} ? 1 : 0;
$vars->{x_labels_vertical} = $ARGS->{x_labels_vertical} ? 1 : 0;
%{Bugzilla::Search->COLUMNS($runner)} = %old_columns;
return $vars;
}
1;
__END__

View File

@ -40,6 +40,7 @@ use constant DB_COLUMNS => qw(
sortkey
onemailperbug
title
isreport
);
use constant NAME_FIELD => 'id';
@ -53,7 +54,7 @@ sub sortkey { return $_[0]->{'sortkey'}; }
sub one_email_per_bug { return $_[0]->{'onemailperbug'}; }
sub title { return $_[0]->{'title'}; }
sub name { return $_[0]->{'query_name'}; }
sub isreport { return $_[0]->{'isreport'}; }
1;

View File

@ -247,6 +247,7 @@ if ($ARGS->{update})
my $title = $ARGS->{"query_title_$qid"} || '';
my $o_onemailperbug = $ARGS->{"orig_query_onemailperbug_$qid"} || 0;
my $onemailperbug = $ARGS->{"query_onemailperbug_$qid"} ? 1 : 0;
my $isreport = 0;
if ($o_sort != $sort || $o_queryname ne $queryname ||
$o_onemailperbug != $onemailperbug || $o_title ne $title)
@ -254,9 +255,13 @@ if ($ARGS->{update})
detaint_natural($sort);
trick_taint($queryname);
trick_taint($title);
if ($queryname =~ /^([01])-(.*)$/s)
{
($isreport, $queryname) = ($1, $2);
}
$dbh->do(
"UPDATE whine_queries SET sortkey=?, query_name=?, title=?, onemailperbug=? WHERE id=?",
undef, $sort, $queryname, $title, $onemailperbug, $qid
"UPDATE whine_queries SET sortkey=?, query_name=?, title=?, onemailperbug=?, isreport=? WHERE id=?",
undef, $sort, $queryname, $title, $onemailperbug, $isreport, $qid
);
}
}
@ -323,6 +328,7 @@ for my $event_id (keys %{$events})
sort => $query->sortkey,
id => $query->id,
onemailperbug => $query->one_email_per_bug,
isreport => $query->isreport,
};
}
}
@ -330,7 +336,8 @@ for my $event_id (keys %{$events})
$vars->{events} = $events;
# get the available queries
$vars->{available_queries} = $dbh->selectcol_arrayref("SELECT name FROM namedqueries WHERE userid=?", undef, $userid) || [];
$vars->{available_queries} = $dbh->selectcol_arrayref("SELECT name FROM namedqueries WHERE userid=? ORDER BY name", undef, $userid) || [];
$vars->{available_reports} = $dbh->selectcol_arrayref("SELECT name FROM reports WHERE user_id=? ORDER BY name", undef, $userid) || [];
$vars->{token} = issue_session_token('edit_whine');
$vars->{local_timezone} = Bugzilla->local_timezone->short_name_for_datetime(DateTime->now());

View File

@ -34,7 +34,6 @@ use Bugzilla::Token;
my $ARGS = Bugzilla->input_params;
my $template = Bugzilla->template;
my $vars = {};
my $buffer = http_build_query($ARGS);
# Go straight back to query.cgi if we are adding a boolean chart.
if (grep /^cmd-/, keys %$ARGS)
@ -104,209 +103,11 @@ elsif ($action eq 'del')
exit;
}
my $valid_columns = Bugzilla::Search->REPORT_COLUMNS();
$vars->{report_columns} = $valid_columns;
my $field = {};
for (qw(x y z))
{
my $f = $ARGS->{$_.'_axis_field'} || '';
trick_taint($f);
if ($f)
{
if ($valid_columns->{$f})
{
$field->{$_} = $f;
}
else
{
ThrowCodeError("report_axis_invalid", {fld => $_, val => $f});
}
}
}
if (!keys %$field)
{
ThrowUserError("no_axes_defined");
}
my $width = $ARGS->{width};
my $height = $ARGS->{height};
if (defined($width))
{
(detaint_natural($width) && $width > 0)
|| ThrowCodeError("invalid_dimensions");
$width <= 2000 || ThrowUserError("chart_too_large");
}
if (defined($height))
{
(detaint_natural($height) && $height > 0)
|| ThrowCodeError("invalid_dimensions");
$height <= 2000 || ThrowUserError("chart_too_large");
}
# These shenanigans are necessary to make sure that both vertical and
# horizontal 1D tables convert to the correct dimension when you ask to
# display them as some sort of chart.
my $is_table;
if ($ARGS->{format} eq 'table' || $ARGS->{format} eq 'simple')
{
$is_table = 1;
if ($field->{x} && !$field->{y})
{
# 1D *tables* should be displayed vertically (with a row_field only)
$field->{y} = $field->{x};
delete $field->{x};
}
}
else
{
if (!Bugzilla->feature('graphical_reports'))
{
ThrowCodeError('feature_disabled', { feature => 'graphical_reports' });
}
if ($field->{y} && !$field->{x})
{
# 1D *charts* should be displayed horizontally (with an col_field only)
$field->{x} = $field->{y};
delete $field->{y};
}
}
my $measures = {
etime => 'estimated_time',
rtime => 'remaining_time',
wtime => 'interval_time',
count => '_count',
};
# Trick Bugzilla::Search: replace report columns SQL + add '_count' column
# FIXME: Remove usage of global variable COLUMNS in search generation code
%{Bugzilla::Search->COLUMNS} = (%{Bugzilla::Search->COLUMNS}, %{Bugzilla::Search->REPORT_COLUMNS});
Bugzilla::Search->COLUMNS->{_count}->{name} = '1';
my $measure = $ARGS->{measure};
if ($measure eq 'times' ? !$is_table : !$measures->{$measure})
{
$measure = 'count';
}
$vars->{measure} = $measure;
# Validate the values in the axis fields or throw an error.
my %a;
my @group_by = grep { !($a{$_}++) } values %$field;
my @axis_fields = @group_by;
for ($measure eq 'times' ? qw(etime rtime wtime) : $measure)
{
push @axis_fields, $measures->{$_} unless $a{$measures->{$_}};
}
# Clone the params, so that Bugzilla::Search can modify them
my $search = new Bugzilla::Search(
'fields' => \@axis_fields,
'params' => { %{ Bugzilla->input_params } },
);
my $query = $search->getSQL();
$query =
"SELECT ".
($field->{x} || "''")." x, ".
($field->{y} || "''")." y, ".
($field->{z} || "''")." z, ".
join(', ', map { "SUM($measures->{$_}) $_" } $measure eq 'times' ? qw(etime rtime wtime) : $measure).
" FROM ($query) _report_table GROUP BY ".join(", ", @group_by);
$::SIG{TERM} = 'DEFAULT';
$::SIG{PIPE} = 'DEFAULT';
my $results = $dbh->selectall_arrayref($query, {Slice=>{}});
# We have a hash of hashes for the data itself, and a hash to hold the
# row/col/table names.
my %data;
my %names;
# Read the bug data and count the bugs for each possible value of row, column
# and table.
#
# We detect a numerical field, and sort appropriately, if all the values are
# numeric.
my %isnumeric;
foreach my $group (@$results)
{
for (qw(x y z))
{
$isnumeric{$_} &&= ($group->{$_} =~ /^-?\d+(\.\d+)?$/o);
$names{$_}{$group->{$_}} = 1;
}
$data{$group->{z}}{$group->{x}}{$group->{y}} = $is_table ? $group : $group->{$measure};
}
my @tbl_names = @{get_names($names{z}, $isnumeric{z}, $field->{z})};
my @col_names = @{get_names($names{x}, $isnumeric{x}, $field->{x})};
my @row_names = @{get_names($names{y}, $isnumeric{y}, $field->{y})};
# The GD::Graph package requires a particular format of data, so once we've
# gathered everything into the hashes and made sure we know the size of the
# data, we reformat it into an array of arrays of arrays of data.
push @tbl_names, "-total-" if scalar(@tbl_names) > 1;
my @image_data;
foreach my $tbl (@tbl_names)
{
my @tbl_data;
push @tbl_data, \@col_names;
foreach my $row (@row_names)
{
my @col_data;
foreach my $col (@col_names)
{
$data{$tbl}{$col}{$row} ||= {};
push @col_data, $data{$tbl}{$col}{$row};
if ($tbl ne "-total-")
{
# This is a bit sneaky. We spend every loop except the last
# building up the -total- data, and then last time round,
# we process it as another tbl, and push() the total values
# into the image_data array.
for my $m (keys %{$data{$tbl}{$col}{$row}})
{
$data{"-total-"}{$col}{$row}{$m} += $data{$tbl}{$col}{$row}{$m};
}
}
}
push @tbl_data, \@col_data;
}
unshift @image_data, \@tbl_data;
}
$vars->{tbl_field} = $field->{z};
$vars->{col_field} = $field->{x};
$vars->{row_field} = $field->{y};
$vars->{time} = localtime(time());
$vars->{col_names} = \@col_names;
$vars->{row_names} = \@row_names;
$vars->{tbl_names} = \@tbl_names;
# Below a certain width, we don't see any bars, so there needs to be a minimum.
if ($width && $ARGS->{format} eq "bar")
{
my $min_width = (scalar(@col_names) || 1) * 20;
if (!$ARGS->{cumulate})
{
$min_width *= (scalar(@row_names) || 1);
}
$vars->{min_width} = $min_width;
}
$vars->{width} = $width if $width;
$vars->{height} = $height if $height;
$vars->{query} = $query;
$vars = { %$vars, %{Bugzilla::Report->execute($ARGS)} };
$vars->{saved_report_id} = $ARGS->{saved_report_id};
$vars->{debug} = $ARGS->{debug};
$vars->{report_columns} = Bugzilla::Search->REPORT_COLUMNS();
my $formatparam = $ARGS->{format};
@ -323,32 +124,17 @@ if ($action eq "wrap")
$vars->{format} = $formatparam;
$formatparam = '' if $formatparam ne 'simple';
# We need to keep track of the defined restrictions on each of the
# axes, because buglistbase, below, throws them away. Without this, we
# get buglistlinks wrong if there is a restriction on an axis field.
$vars->{col_vals} = join("&", $buffer =~ /[&?]($field->{x}=[^&]+)/g);
$vars->{row_vals} = join("&", $buffer =~ /[&?]($field->{y}=[^&]+)/g);
$vars->{tbl_vals} = join("&", $buffer =~ /[&?]($field->{z}=[^&]+)/g);
# We need a number of different variants of the base URL for different URLs in the HTML.
my $a = { %$ARGS };
delete $a->{$_} for qw(x_axis_field y_axis_field z_axis_field ctype format query_format measure), @axis_fields;
$vars->{buglistbase} = http_build_query($a);
$a = { %$ARGS };
delete $a->{$_} for $field->{z}, qw(action ctype format width height);
delete $a->{$_} for $vars->{fields}->{z}, qw(action ctype format width height);
$vars->{imagebase} = http_build_query($a);
$a = { %$ARGS };
delete $a->{$_} for qw(query_format action ctype format width height measure);
$vars->{switchbase} = http_build_query($a);
$vars->{data} = \%data;
}
elsif ($action eq "plot")
{
# If action is "plot", we will be using a format as normal (pie, bar etc.)
# and a ctype as normal (currently only png.)
$vars->{cumulate} = $ARGS->{cumulate} ? 1 : 0;
$vars->{x_labels_vertical} = $ARGS->{x_labels_vertical} ? 1 : 0;
$vars->{data} = \@image_data;
}
else
{
@ -376,9 +162,9 @@ if ($ARGS->{debug})
{
require Data::Dumper;
print "<pre>data hash:\n";
print html_quote(Data::Dumper::Dumper(%data)) . "\n\n";
print html_quote(Data::Dumper::Dumper($vars->{data})) . "\n\n";
print "data array:\n";
print html_quote(Data::Dumper::Dumper(@image_data)) . "\n\n</pre>";
print html_quote(Data::Dumper::Dumper($vars->{image_data})) . "\n\n</pre>";
}
# All formats point to the same section of the documentation.
@ -390,30 +176,3 @@ $template->process($format->{template}, $vars)
|| ThrowTemplateError($template->error());
exit;
sub get_names
{
my ($names, $isnumeric, $field) = @_;
# These are all the fields we want to preserve the order of in reports.
my $f = Bugzilla->get_field($field);
if ($f && $f->is_select)
{
my $values = [ '', map { $_->name } @{ $f->legal_values(1) } ];
my %dup;
@$values = grep { exists($names->{$_}) && !($dup{$_}++) } @$values;
return $values;
}
elsif ($isnumeric)
{
# It's not a field we are preserving the order of, so sort it
# numerically...
sub numerically { $a <=> $b }
return [ sort numerically keys %$names ];
}
else
{
# ...or alphabetically, as appropriate.
return [ sort keys %$names ];
}
}

View File

@ -946,13 +946,16 @@ table.tabs {
}
table.eventbox {
border-color: gray;
padding: 5px;
border-color: white;
background: white;
border-radius: 5px;
box-shadow: 2px 2px 3px 0 rgba(0, 0, 0, 0.2);
}
table.eventbox td.set {
background: #e0e0e0;
}
/* search */
#summary_field.search_field_row input {

View File

@ -95,16 +95,16 @@ td.forbidden {
}
table.eventbox {
border: 1px solid black;
border: 10px solid white;
margin: 8px 0;
}
td.set {
table.eventbox td.set {
background: #ddd;
padding: 5px;
}
td.unset {
table.eventbox td.unset {
color: red;
}

View File

@ -22,8 +22,8 @@
[% col_field_disp = field_descs.$col_field || Bugzilla.get_field(col_field).description || col_field %]
[% FOR i IN [ 0 .. data.0.0.max ] %]
[% data.0.0.$i = data.0.0.$i %]
[% FOR i IN [ 0 .. image_data.0.0.max ] %]
[% image_data.0.0.$i = image_data.0.0.$i %]
[% END %]
[% FOR i IN [ 0 .. row_names.max ] %]
@ -63,6 +63,6 @@
row_names.8, row_names.9, row_names.10, row_names.11,
row_names.12, row_names.13, row_names.14, row_names.15);
graph.plot(data.0).png | stdout(1);
graph.plot(image_data.0).png | stdout(1);
END;
-%]

View File

@ -22,8 +22,8 @@
[% col_field_disp = field_descs.$col_field || Bugzilla.get_field(col_field).description || col_field %]
[% FOR i IN [ 0 .. data.0.0.max ] %]
[% data.0.0.$i = data.0.0.$i %]
[% FOR i IN [ 0 .. image_data.0.0.max ] %]
[% image_data.0.0.$i = image_data.0.0.$i %]
[% END %]
[% IF cumulate %]
@ -61,7 +61,7 @@
row_names.8, row_names.9, row_names.10, row_names.11,
row_names.12, row_names.13, row_names.14, row_names.15);
graph.plot(data.0).png | stdout(1);
graph.plot(image_data.0).png | stdout(1);
END;
-%]

View File

@ -20,8 +20,8 @@
[% col_field_disp = field_descs.$col_field || Bugzilla.get_field(col_field).description || col_field %]
[% FOR i IN [ 0 .. data.0.0.max ] %]
[% data.0.0.$i = data.0.0.$i %]
[% FOR i IN [ 0 .. image_data.0.0.max ] %]
[% image_data.0.0.$i = image_data.0.0.$i %]
[% END %]
[% FILTER null;
@ -37,6 +37,6 @@
graph.set_label_font(Param('graph_font'), Param('graph_font_size'));
graph.set_value_font(Param('graph_font'), Param('graph_font_size'));
graph.plot(data.0).png | stdout(1);
graph.plot(image_data.0).png | stdout(1);
END;
-%]

View File

@ -33,14 +33,6 @@
# cumulate: boolean. For bar/line charts, whether to cumulate data sets.
#%]
[% DEFAULT width = 600
height = 350
%]
[% IF min_width AND width < min_width %]
[% width = min_width %]
[% END %]
[%# We ignore row_field for pie charts %]
[% IF format == "pie" %]
[% row_field = "" %]

View File

@ -58,13 +58,17 @@
<h2>[%+ query.title FILTER html %]</h2>
[% code = BLOCK %]
[% PROCESS "list/table.html.tmpl"
bugs = query.bugs
order_columns = query.order_columns
order = query.order_columns.join(',')
displaycolumns = query.displaycolumns
template_format = 'simple'
%]
[% IF query.isreport %]
[% "whinereport" | process(query.data) %]
[% ELSE %]
[% PROCESS "list/table.html.tmpl"
bugs = query.bugs
order_columns = query.order_columns
order = query.order_columns.join(',')
displaycolumns = query.displaycolumns
template_format = 'simple'
%]
[% END %]
[% END %]
[% code.replace('<a([^>]*)href="([a-z_]+)\.cgi', '<a$1href="' _ urlbase _ '$2.cgi') | none %]
@ -72,3 +76,16 @@
</body>
</html>
[% BLOCK whinereport %]
<div align="center">
[% FOREACH tbl = tbl_names %]
[% IF tbl == "-total-" %]
[% tbl_disp = "Total" %]
[% ELSE %]
[% tbl_disp = tbl %]
[% END %]
[% PROCESS "reports/report-table.html.tmpl" %]
[% END %]
</div>
[% END %]

View File

@ -244,7 +244,7 @@
<table>
<tr>
<th>Sort</th>
<th>Search</th>
<th>Search/Report</th>
<th>Title</th>
<th></th>
<th></th>
@ -260,9 +260,9 @@
name="orig_query_sort_[% query.id %]" />
</td>
<td align="left">
<input type="hidden" value="[% query.name FILTER html %]"
<input type="hidden" value="[% query.isreport %]-[% query.name FILTER html %]"
name="orig_query_name_[% query.id %]" />
[% PROCESS query_field thisquery=query.name %]
[% PROCESS query_field thisquery=query.name isreport=query.isreport %]
</td>
<td align="left">
<input type="hidden" value="[% query.title FILTER html %]"
@ -321,12 +321,17 @@
[% BLOCK query_field +%]
[% IF available_queries.size > 0 %]
[% IF available_queries.size > 0 || available_reports.size > 0 %]
<select name="query_name_[% query.id %]">
[% FOREACH q = available_queries %]
<option [% "selected" IF q == thisquery %] value="[% q FILTER html %]">
[% q FILTER html %]
<option [% "selected" IF q == thisquery && !isreport %] value="0-[% q FILTER html %]">
[% q FILTER html %]
</option>
[% END %]
[% FOREACH q = available_reports %]
<option [% "selected" IF q == thisquery && isreport %] value="1-[% q FILTER html %]">
Report: [% q FILTER html %]
</option>
[% END %]
</select>

View File

@ -29,6 +29,9 @@ use Bugzilla::User;
use Bugzilla::Mailer;
use Bugzilla::Util;
use Bugzilla::Group;
use Bugzilla::Report;
Bugzilla->set_user(Bugzilla::User->super_user);
# %seen_schedules is a list of all of the schedules that have already been
# touched by reset_timer. If reset_timer sees a schedule more than once, it
@ -176,7 +179,7 @@ while (my $event = get_next_event())
my $there_are_bugs = 0;
for my $query (@{$queries})
{
$there_are_bugs = 1 if scalar @{$query->{bugs}};
$there_are_bugs = 1 if $query->{isreport} || scalar @{$query->{bugs}};
}
next unless $there_are_bugs;
}
@ -320,6 +323,8 @@ sub mail
# Don't send mail to someone whose bugmail notification is disabled.
return if $addressee->email_disabled;
$args->{report_columns} = Bugzilla::Search->REPORT_COLUMNS();
my $template = Bugzilla->template_inner($addressee->settings->{lang}->{value});
my $msg = ''; # it's a temporary variable to hold the template output
$args->{alternatives} ||= [];
@ -373,13 +378,26 @@ sub run_queries
my $dbh = Bugzilla->dbh;
my $queries = $dbh->selectall_arrayref(
"SELECT query_name, title, onemailperbug FROM whine_queries".
"SELECT query_name, title, onemailperbug, isreport FROM whine_queries".
" WHERE eventid=? ORDER BY sortkey", {Slice=>{}}, $args->{eventid}
);
foreach my $thisquery (@$queries)
{
next unless $thisquery->{query_name}; # named query is blank
if ($thisquery->{isreport})
{
my ($savedreport) = @{ Bugzilla::Report->match({ name => $thisquery->{query_name}, user_id => $args->{author}->id }) };
next unless $savedreport; # silently ignore missing reports
my $params = http_decode_query($savedreport->query);
$thisquery->{data} = Bugzilla::Report->execute($params, $args->{author});
if (@{$thisquery->{data}->{image_data}})
{
push @$return_queries, $thisquery;
}
next;
}
my $savedquery = Bugzilla::Search::Saved->new({ name => $thisquery->{query_name}, user => $args->{author} });
next unless $savedquery; # silently ignore missing queries