Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
bugzilla
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
etersoft
bugzilla
Commits
48f3c648
Commit
48f3c648
authored
Dec 08, 2010
by
Frédéric Buclin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Bug 617630: Improve get_names() in report.cgi
a=LpSolit
parent
9b146191
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
35 deletions
+20
-35
report.cgi
report.cgi
+20
-35
No files found.
report.cgi
View file @
48f3c648
...
@@ -29,6 +29,8 @@ use Bugzilla::Constants;
...
@@ -29,6 +29,8 @@ use Bugzilla::Constants;
use
Bugzilla::
Util
;
use
Bugzilla::
Util
;
use
Bugzilla::
Error
;
use
Bugzilla::
Error
;
use
Bugzilla::
Field
;
use
Bugzilla::
Field
;
use
Bugzilla::
Search
;
use
List::
MoreUtils
qw(uniq)
;
use
List::
MoreUtils
qw(uniq)
;
my
$cgi
=
Bugzilla
->
cgi
;
my
$cgi
=
Bugzilla
->
cgi
;
...
@@ -46,8 +48,6 @@ if (grep(/^cmd-/, $cgi->param())) {
...
@@ -46,8 +48,6 @@ if (grep(/^cmd-/, $cgi->param())) {
exit
;
exit
;
}
}
use
Bugzilla::
Search
;
Bugzilla
->
login
();
Bugzilla
->
login
();
my
$dbh
=
Bugzilla
->
switch_to_shadow_db
();
my
$dbh
=
Bugzilla
->
switch_to_shadow_db
();
...
@@ -178,9 +178,9 @@ foreach my $result (@$results) {
...
@@ -178,9 +178,9 @@ foreach my $result (@$results) {
$tbl_isnumeric
&&=
(
$tbl
=~
/^-?\d+(\.\d+)?$/o
);
$tbl_isnumeric
&&=
(
$tbl
=~
/^-?\d+(\.\d+)?$/o
);
}
}
my
@col_names
=
@
{
get_names
(
$names
{
"col"
},
$col_isnumeric
,
$col_field
)}
;
my
@col_names
=
get_names
(
$names
{
"col"
},
$col_isnumeric
,
$col_field
)
;
my
@row_names
=
@
{
get_names
(
$names
{
"row"
},
$row_isnumeric
,
$row_field
)}
;
my
@row_names
=
get_names
(
$names
{
"row"
},
$row_isnumeric
,
$row_field
)
;
my
@tbl_names
=
@
{
get_names
(
$names
{
"tbl"
},
$tbl_isnumeric
,
$tbl_field
)}
;
my
@tbl_names
=
get_names
(
$names
{
"tbl"
},
$tbl_isnumeric
,
$tbl_field
)
;
# The GD::Graph package requires a particular format of data, so once we've
# 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
# gathered everything into the hashes and made sure we know the size of the
...
@@ -312,44 +312,29 @@ disable_utf8() if ($format->{'ctype'} =~ /^image\//);
...
@@ -312,44 +312,29 @@ disable_utf8() if ($format->{'ctype'} =~ /^image\//);
$template
->
process
(
"$format->{'template'}"
,
$vars
)
$template
->
process
(
"$format->{'template'}"
,
$vars
)
||
ThrowTemplateError
(
$template
->
error
());
||
ThrowTemplateError
(
$template
->
error
());
exit
;
sub
get_names
{
sub
get_names
{
my
(
$names
,
$isnumeric
,
$field
)
=
@_
;
my
(
$names
,
$isnumeric
,
$field_name
)
=
@_
;
# These are all the fields we want to preserve the order of in reports.
my
(
$field
,
@sorted
);
my
%
fields
;
$field
=
Bugzilla::
Field
->
check
(
$field_name
)
if
$field_name
;
my
@select_fields
=
@
{
Bugzilla
->
fields
({
is_select
=>
1
})
};
foreach
my
$field
(
@select_fields
)
{
if
(
$field
&&
$field
->
is_select
)
{
my
@names
=
map
(
$_
->
name
,
@
{
$field
->
legal_values
});
foreach
my
$value
(
@
{
$field
->
legal_values
})
{
unshift
@names
,
' '
if
$field
->
name
eq
'resolution'
;
push
(
@sorted
,
$value
->
name
)
if
$names
->
{
$value
->
name
};
$fields
{
$field
->
name
}
=
[
uniq
@names
];
}
my
$field_list
=
$fields
{
$field
};
my
@sorted
;
if
(
$field_list
)
{
my
@unsorted
=
keys
%
{
$names
};
# Extract the used fields from the field_list, in the order they
# appear in the field_list. This lets us keep e.g. severities in
# the normal order.
#
# This is O(n^2) but it shouldn't matter for short lists.
foreach
my
$item
(
@$field_list
)
{
push
(
@sorted
,
$item
)
if
grep
{
$_
eq
$item
}
@unsorted
;
}
}
unshift
(
@sorted
,
' '
)
if
$field_name
eq
'resolution'
;
@sorted
=
uniq
@sorted
;
}
}
elsif
(
$isnumeric
)
{
elsif
(
$isnumeric
)
{
# It's not a field we are preserving the order of, so sort it
# It's not a field we are preserving the order of, so sort it
# numerically...
# numerically...
sub
numerically
{
$a
<=>
$b
}
@sorted
=
sort
{
$a
<=>
$b
}
keys
%
$names
;
@sorted
=
sort
numerically
keys
(
%
{
$names
});
}
}
else
{
else
{
# ...or alphabetically, as appropriate.
# ...or alphabetically, as appropriate.
@sorted
=
sort
(
keys
(
%
{
$names
}))
;
@sorted
=
sort
keys
%
$names
;
}
}
return
\
@sorted
;
return
@sorted
;
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment