View Issue Details

IDProjectCategoryView StatusLast Update
0010129mantisbtcustomizationpublic2017-09-03 05:31
ReporterKirill Assigned Toatrol  
PrioritynormalSeverityfeatureReproducibilityhave not tried
Status closedResolutionwon't fix 
Summary0010129: Exclude some statuses in percent legend
Description

May be create in config some value, that filter which status not showing?

TagsNo tags attached.
Attached Files
mantis.diff (4,283 bytes)   
diff --git a/config_defaults_inc.php b/config_defaults_inc.php
index 937c477..05dec5a 100644
--- a/config_defaults_inc.php
+++ b/config_defaults_inc.php
@@ -978,6 +978,14 @@ $g_status_legend_position = STATUS_LEGEND_POSITION_BOTTOM;
 $g_status_percentage_legend = OFF;
 
 /**
+ * Do not include status levels above this in the status percentage
+ * bar. Useful for hiding issues above resolved/closed to show more useful
+ * "working" percentages.
+ * @global int $g_status_percentage_legend_hide_level
+ */
+$g_status_percentage_legend_hide = CLOSED;
+
+/**
  * Position of the filter box, can be: POSITION_*
  * POSITION_TOP, POSITION_BOTTOM, or POSITION_NONE for none.
  * @global int $g_filter_position
diff --git a/core/html_api.php b/core/html_api.php
index f7ae556..4b97d42 100644
--- a/core/html_api.php
+++ b/core/html_api.php
@@ -1218,7 +1218,7 @@ function print_summary_menu( $p_page = '' ) {
  * @param string
  * @return null
  */
-function html_status_legend() {
+function html_status_legend( $p_use_filter = false ) {
 	echo '<br />';
 	echo '<table class="width100" cellspacing="1">';
 	echo '<tr>';
@@ -1285,7 +1285,7 @@ function html_status_legend() {
 	echo '</tr>';
 	echo '</table>';
 	if( ON == config_get( 'status_percentage_legend' ) ) {
-		html_status_percentage_legend();
+		html_status_percentage_legend($p_use_filter);
 	}
 }
 
@@ -1293,27 +1293,49 @@ function html_status_legend() {
  * Print the legend for the status percentage
  * @return null
  */
-function html_status_percentage_legend() {
+function html_status_percentage_legend( $p_use_filter = false ) {
 	$t_mantis_bug_table = db_get_table( 'bug' );
 	$t_project_id = helper_get_current_project();
 	$t_user_id = auth_get_current_user_id();
 
-	# checking if it's a per project statistic or all projects
-	$t_specific_where = helper_project_specific_where( $t_project_id, $t_user_id );
-
-	$query = "SELECT status, COUNT(*) AS number
-				FROM $t_mantis_bug_table
-				WHERE $t_specific_where
-				GROUP BY status";
-	$result = db_query_bound( $query );
-
 	$t_bug_count = 0;
 	$t_status_count_array = array();
 
-	while( $row = db_fetch_array( $result ) ) {
-		$t_status_count_array[$row['status']] = $row['number'];
-		$t_bug_count += $row['number'];
-	}
+	# Use current filter
+	if ( $p_use_filter ) {
+		$t_filter = current_user_get_bug_filter();
+		if ( !$t_filter ) $t_filter = filter_get_default();
+
+		# Get data
+		$t_page_num = 0;
+		$t_per_page = -1;
+		$t_page_count = 0;
+		$rows = filter_get_bug_rows($t_page_num, $t_per_page, $t_page_count, $t_bug_count);
+
+		# Process
+		foreach ( $rows as $row ) {
+			$t_status_count_array[$row->status]++;
+		}
+
+	# Default to project list
+	} else {
+		$t_hide_level = config_get('status_percentage_legend_hide');
+
+		# checking if it's a per project statistic or all projects
+		$t_specific_where = helper_project_specific_where( $t_project_id, $t_user_id );
+
+		$query = "SELECT status, COUNT(*) AS number
+					FROM $t_mantis_bug_table
+					WHERE $t_specific_where AND
+					status < $t_hide_level
+				  GROUP BY status";
+		$result = db_query_bound( $query );
+
+		while( $row = db_fetch_array( $result ) ) {
+			$t_status_count_array[$row['status']] = $row['number'];
+			$t_bug_count += $row['number'];
+    }
+  }
 
 	$t_enum_values = MantisEnum::getValues( config_get( 'status_enum_string' ) );
 	$enum_count = count( $t_enum_values );
diff --git a/view_all_inc.php b/view_all_inc.php
index cc385be..3c621cb 100644
--- a/view_all_inc.php
+++ b/view_all_inc.php
@@ -92,7 +92,7 @@ if ( ( $t_filter_position & FILTER_POSITION_TOP ) == FILTER_POSITION_TOP ) {
 $t_status_legend_position = config_get( 'status_legend_position' );
 
 if ( $t_status_legend_position == STATUS_LEGEND_POSITION_TOP || $t_status_legend_position == STATUS_LEGEND_POSITION_BOTH ) {
-	html_status_legend();
+	html_status_legend(true);
 }
 
 /** @todo (thraxisp) this may want a browser check  ( MS IE >= 5.0, Mozilla >= 1.0, Safari >=1.2, ...) */
@@ -259,7 +259,7 @@ write_bug_rows($rows);
 <?php
 
 if ( $t_status_legend_position == STATUS_LEGEND_POSITION_BOTTOM || $t_status_legend_position == STATUS_LEGEND_POSITION_BOTH ) {
-	html_status_legend();
+	html_status_legend(true);
 }
 
 # -- ====================== FILTER FORM ========================= --
mantis.diff (4,283 bytes)   

Relationships

has duplicate 0008529 closedatrol Issue Status Percentage Bar graph maximum status to graph (ie. Exclude closed etc) 
related to 0017551 new Roadmap Feature shows only percentage Resolved 

Activities

thraxisp

thraxisp

2009-02-11 08:49

reporter   ~0020835

The status won't show in the percentage bar if there are no entries at that status.

Could you describe the problem in more detail?

Kirill

Kirill

2009-02-11 11:05

reporter   ~0020837

Last edited: 2009-02-11 11:06

No problems. It's only wish
I want modify code
$query = "SELECT status, COUNT(*) AS number
FROM $t_mantis_bug_table
WHERE $t_specific_where
GROUP BY status";

to
$query = "SELECT status, COUNT(*) AS number
FROM $t_mantis_bug_table
WHERE $t_specific_where and status < 90
GROUP BY status";
but this not universal method.
May be set in config new property witch statuses exclude?

thraxisp

thraxisp

2009-02-11 11:24

reporter   ~0020838

Updated description, and flagged as feature.

vboctor

vboctor

2009-10-23 01:38

manager   ~0023291

Should we just exclude $g_bug_closed_status_threshold or do you think we need this to have a separate configuration option. For example, some users may want to exclude $g_bug_resolved_status_threshold or whatever custom status?

atrol

atrol

2009-10-23 02:44

developer   ~0023292

For me at the moment $g_bug_resolved_status_threshold is what I need.

The most flexible solution would be a new configuration with an array not a treshold.

Kirill

Kirill

2009-10-23 02:56

reporter   ~0023293

I agree with atrol.
This must be array - what exclude.

vboctor

vboctor

2009-10-24 01:07

manager   ~0023306

Sounds reasonable. Patches are welcome.

aps

aps

2010-03-11 07:20

reporter   ~0024699

I decided to take a look at this as it was bugging me on my work setup and it looked fairly trivial to fix.

I've attached a patch (diff'd against git latest as of a few mins ago, I'm new to git so not sure how you specify which "revision" that is).

I've included a global configuration value (feel free to rename to something better) that is used to exclude statuses above a given threshold.

Additionally the status legend function takes a "use_filter" parameter which is passed through the percentage function. If this is set then the percentage bar only shows info for those bugs covered by the current filter (this was the main thing I wanted). This is made use of by called html_status_length(true) from within view_all_inc.php. This will also fix 0009537.

Any problems let me know.

djcarr

djcarr

2010-07-07 00:41

reporter   ~0026030

Last edited: 2010-07-07 00:50

I have tried the mantis.diff. Unfortunately it doesn't seem to scale well.

On a project with a couple of hundred issues, it works perfectly.

However as soon as I selected a project with 6000+ issues, Mantis hung up, displaying a white screen and churning endlessly.

This patch does involve a second call to filter_get_bug_rows() which is computationally really expensive.

Is it possible to optimise this patch further?

atrol

atrol

2017-08-14 12:19

developer   ~0057454

The status percentage legend has been removed in version 2.x.