Skip to content

Commit

Permalink
Fix for patch [4314]:
Browse files Browse the repository at this point in the history
Optimized database query
Added description line
Issue Status Percentage legend shown above or below the status legend depending on the position of the status legend.


git-svn-id: http://mantisbt.svn.sourceforge.net/svnroot/mantisbt/trunk@3206 f5dc347c-c33d-0410-90a0-b07cc1902cb9
  • Loading branch information
bpfennigschmidt committed Dec 18, 2004
1 parent fb26b2a commit 4af0df4
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 22 deletions.
39 changes: 21 additions & 18 deletions core/html_api.php
Expand Up @@ -6,7 +6,7 @@
# See the README and LICENSE files for details

# --------------------------------------------------------
# $Id: html_api.php,v 1.143 2004-12-18 12:23:57 vboctor Exp $
# $Id: html_api.php,v 1.144 2004-12-18 19:32:03 bpfennigschmidt Exp $
# --------------------------------------------------------

###########################################################################
Expand Down Expand Up @@ -694,6 +694,7 @@ function html_status_legend() {
# --------------------
# Print the legend for the status percentage
function html_status_percentage_legend() {

$t_mantis_bug_table = config_get( 'mantis_bug_table' );
$t_project_id = helper_get_current_project();
$t_user_id = auth_get_current_user_id();
Expand All @@ -711,43 +712,45 @@ function html_status_percentage_legend() {
$t_specific_where = "WHERE project_id='$t_project_id'";
}

# Can't we use a more efficient query that is based on DISTINCT statuses + COUNT?
$query = "SELECT status
$query = "SELECT status, COUNT(*) AS number
FROM $t_mantis_bug_table
$t_specific_where";
$t_specific_where
GROUP BY status";
$result = db_query( $query );

$t_bug_count = db_num_rows( $result );
$t_bug_count = 0;
$t_status_count_array = array();

while ( $row = db_fetch_array( $result ) ) {
$t_current_status = $row['status'];

if ( isset( $t_status_count_array[$t_current_status] ) ) {
$t_status_count_array[$t_current_status]++;
} else {
$t_status_count_array[$t_current_status] = 1;
}

$t_status_count_array[ $row['status'] ] = $row['number'];
$t_bug_count += $row['number'];
}

echo '<table class="width100" cellspacing="0">';
echo '<tr>';


$t_arr = explode_enum_string( config_get( 'status_enum_string' ) );
$enum_count = count( $t_arr );

echo '<br />';
echo '<table class="width100" cellspacing="1">';
echo '<tr colspan="'.$enum_count.'">';
echo '<td><strong>'.lang_get( 'issue_status_percentage' ).'</strong></td>';
echo '</tr>';
echo '<tr>';

for ( $i=0; $i < $enum_count; $i++) {
$t_s = explode_enum_arr( $t_arr[$i] );
$t_color = get_status_color( $t_s[0] );
$t_status = $t_s[0];


if ( !isset( $t_status_count_array[ $t_status ] ) ) {
$t_status_count_array[ $t_status ] = 0;
}

$width = round( ( $t_status_count_array[ $t_status ] / $t_bug_count ) * 100 );

if ($width > 0) {
PRINT "<td class=\"small-caption-center\" width=\"$width%\" bgcolor=\"$t_color\">$width%</td>";
echo "<td class=\"small-caption-center\" width=\"$width%\" bgcolor=\"$t_color\">$width%</td>";
}
}

Expand Down
10 changes: 6 additions & 4 deletions lang/strings_english.txt
Expand Up @@ -9,11 +9,11 @@
###########################################################################
# English strings for Mantis
# -------------------------------------------------
# $Revision: 1.226 $
# $Author: thraxisp $
# $Date: 2004-12-18 02:02:29 $
# $Revision: 1.227 $
# $Author: bpfennigschmidt $
# $Date: 2004-12-18 19:32:28 $
#
# $Id: strings_english.txt,v 1.226 2004-12-18 02:02:29 thraxisp Exp $
# $Id: strings_english.txt,v 1.227 2004-12-18 19:32:28 bpfennigschmidt Exp $
###########################################################################

# Charset
Expand Down Expand Up @@ -260,6 +260,8 @@ $s_administrator = 'administrator';
$s_myself = "Myself";
$s_default_access_level = 'Default access level';

$s_issue_status_percentage = 'Issue Status Percentage';

# Enum Strings
$s_access_levels_enum_string = '10:viewer,25:reporter,40:updater,55:developer,70:manager,90:administrator';
$s_project_status_enum_string = '10:development,30:release,50:stable,70:obsolete';
Expand Down

0 comments on commit 4af0df4

Please sign in to comment.