From: <thr...@us...> - 2008-01-12 01:41:39
|
Revision: 4877 http://mantisbt.svn.sourceforge.net/mantisbt/?rev=4877&view=rev Author: thraxisp Date: 2008-01-11 17:41:35 -0800 (Fri, 11 Jan 2008) Log Message: ----------- fix for #8732: Many options on bug_graph_page.php broken, inconsistent, incomplete clean up status graph to handle missing values and datapoints Modified Paths: -------------- branches/BRANCH_1_1_0/mantisbt/bug_graph_bycategory.php branches/BRANCH_1_1_0/mantisbt/bug_graph_bystatus.php branches/BRANCH_1_1_0/mantisbt/bug_graph_page.php branches/BRANCH_1_1_0/mantisbt/core/graph_api.php Modified: branches/BRANCH_1_1_0/mantisbt/bug_graph_bycategory.php =================================================================== --- branches/BRANCH_1_1_0/mantisbt/bug_graph_bycategory.php 2008-01-12 00:04:29 UTC (rev 4876) +++ branches/BRANCH_1_1_0/mantisbt/bug_graph_bycategory.php 2008-01-12 01:41:35 UTC (rev 4877) @@ -197,7 +197,13 @@ // sort and display the results sort($t_category); if ($f_show_as_table) { - echo '<html><body><table class="width100"><tr><td></td>'; + html_begin(); + html_head_begin(); + html_css(); + html_content_type(); + html_head_end(); + html_body_begin(); + echo '<table class="width100"><tr><td></td>'; foreach ( $t_category as $t_cat ) { echo '<th>'.$t_cat.'</th>'; } @@ -209,7 +215,9 @@ } echo '</tr>'; } - echo '</table></body></html>'; + echo '</table>'; + html_body_end(); + html_end(); } else { // reverse the array and reorder the data, if necessary $t_metrics = array(); Modified: branches/BRANCH_1_1_0/mantisbt/bug_graph_bystatus.php =================================================================== --- branches/BRANCH_1_1_0/mantisbt/bug_graph_bystatus.php 2008-01-12 00:04:29 UTC (rev 4876) +++ branches/BRANCH_1_1_0/mantisbt/bug_graph_bystatus.php 2008-01-12 01:41:35 UTC (rev 4877) @@ -76,25 +76,21 @@ $t_status_arr = get_enum_to_array( config_get( 'status_enum_string' ) ); $t_bug = array(); + $t_view_status = array(); // walk through all issues and grab their status for 'now' $t_marker[$t_ptr] = time(); - foreach ( $t_status_arr as $t_status => $t_label ) { - $t_data[$t_ptr][$t_status] = 0; - } foreach ($rows as $t_row) { - $t_data[$t_ptr][$t_row['status']] ++; + if ( isset( $t_data[$t_ptr][$t_row['status']] ) ) { + $t_data[$t_ptr][$t_row['status']] ++; + } else { + $t_data[$t_ptr][$t_row['status']] = 1; + $t_view_status[$t_row['status']] = + isset($t_status_arr[$t_row['status']]) ? $t_status_arr[$t_row['status']] : '@'.$t_row['status'].'@'; + } $t_bug[] = $t_row['id']; } - if ($f_show_as_table) { - echo '<html><body><table class="width100"><tr><td></td>'; - foreach ( $t_status_arr as $t_status => $t_label ) { - echo '<th>'.$t_label.' ('.$t_status.')</th>'; - } - echo '</tr>'; - } - // get the history for these bugs over the interval required to offset the data // type = 0 and field=status are status changes // type = 1 are new bugs @@ -104,81 +100,133 @@ or type='.NEW_BUG.' ) and date_modified >= \''.db_date( $t_start ).'\''. ' order by date_modified DESC'; $t_result = db_query( $t_select ); - $row = db_fetch_array( $t_result ); + $t_row = db_fetch_array( $t_result ); for ($t_now = time() - $t_incr; $t_now >= $t_start; $t_now -= $t_incr) { // walk through the data points and use the data retrieved to update counts - while( ( $row !== false ) && ( db_unixtimestamp($row['date_modified']) >= $t_now ) ) { - switch ($row['type']) { + while( ( $t_row !== false ) && ( db_unixtimestamp($t_row['date_modified']) >= $t_now ) ) { + switch ($t_row['type']) { case 0: // updated bug - $t_data[$t_ptr][$row['new_value']]--; - $t_data[$t_ptr][$row['old_value']]++; + if ( isset( $t_data[$t_ptr][$t_row['new_value']] ) ) { + if ( $t_data[$t_ptr][$t_row['new_value']] > 0 ) + $t_data[$t_ptr][$t_row['new_value']] --; + } else { + $t_data[$t_ptr][$t_row['new_value']] = 0; + $t_view_status[$t_row['new_value']] = + isset($t_status_arr[$t_row['new_value']]) ? $t_status_arr[$t_row['new_value']] : '@'.$t_row['new_value'].'@'; + } + if ( isset( $t_data[$t_ptr][$t_row['old_value']] ) ) { + $t_data[$t_ptr][$t_row['old_value']] ++; + } else { + $t_data[$t_ptr][$t_row['old_value']] = 1; + $t_view_status[$t_row['old_value']] = + isset($t_status_arr[$t_row['old_value']]) ? $t_status_arr[$t_row['old_value']] : '@'.$t_row['old_value'].'@'; + } break; case 1: // new bug - $t_data[$t_ptr][NEW_]--; + if ( isset( $t_data[$t_ptr][NEW_] ) ) { + if ( $t_data[$t_ptr][NEW_] > 0 ) + $t_data[$t_ptr][NEW_] --; + } else { + $t_data[$t_ptr][NEW_] = 0; + $t_view_status[NEW_] = + isset($t_status_arr[NEW_]) ? $t_status_arr[NEW_] : '@'.NEW_.'@'; + } break; } - $row = db_fetch_array( $t_result ); + $t_row = db_fetch_array( $t_result ); } - if ( $f_show_as_table && ($t_now <= $t_end) ) { - echo '<tr class="row-'.($t_ptr%2+1).'"><td>'.$t_ptr.' ('.db_date( $t_now ).')'.'</td>'; - foreach ( $t_status_arr as $t_status => $t_label ) { - echo '<td>'.$t_data[$t_ptr][$t_status].'</td>'; - } - echo '</tr>'; - } - if ($t_now <= $t_end) { $t_ptr++; $t_marker[$t_ptr] = $t_now; - foreach ( $t_status_arr as $t_status => $t_label ) { + foreach ( $t_view_status as $t_status => $t_label ) { $t_data[$t_ptr][$t_status] = $t_data[$t_ptr-1][$t_status]; } } } + ksort($t_view_status); + + // add headers for table if ($f_show_as_table) { - echo '</table></body></html>'; - } else { - $t_resolved = config_get( 'bug_resolved_status_threshold' ); - $t_closed = CLOSED; - $t_bin_count = $t_ptr; - $t_labels = array(); - $i = 0; + html_begin(); + html_head_begin(); + html_css(); + html_content_type(); + html_head_end(); + html_body_begin(); + echo '<table class="width100"><tr><td></td>'; if ($f_summary) { - $t_labels[++$i] = 'open'; - $t_labels[++$i] = 'resolved'; - $t_labels[++$i] = 'closed'; + echo '<th>' . lang_get_defaulted('open') . '</th>'; + echo '<th>' . lang_get_defaulted('resolved') . '</th>'; + echo '<th>' . lang_get_defaulted('closed') . '</th>'; } else { - foreach ( $t_status_arr as $t_status => $t_label ) { - $t_labels[++$i] = $t_label; - } - } - // reverse the array and consolidate the data, if necessary - $t_metrics = array(); - for ($t_ptr=0; $t_ptr<$t_bin_count; $t_ptr++) { - $t = $t_bin_count - $t_ptr; - $t_metrics[0][$t_ptr] = $t_marker[$t]; - if ($f_summary) { - $t_metrics[1][$t_ptr] = 0; - $t_metrics[2][$t_ptr] = 0; - $t_metrics[3][$t_ptr] = 0; - foreach ( $t_status_arr as $t_status => $t_label ) { + foreach ( $t_view_status as $t_status => $t_label ) { + echo '<th>'.$t_label.' ('.$t_status.')</th>'; + } + } + echo '</tr>'; + } + + $t_resolved = config_get( 'bug_resolved_status_threshold' ); + $t_closed = CLOSED; + $t_bin_count = $t_ptr; + $t_labels = array(); + $i = 0; + if ($f_summary) { + $t_labels[++$i] = 'open'; + $t_labels[++$i] = 'resolved'; + $t_labels[++$i] = 'closed'; + } else { + foreach ( $t_view_status as $t_status => $t_label ) { + $t_labels[++$i] = $t_label; + } + } + $t_label_count = $i; + + // reverse the array and consolidate the data, if necessary + $t_metrics = array(); + for ($t_ptr=0; $t_ptr<$t_bin_count; $t_ptr++) { + $t = $t_bin_count - $t_ptr; + $t_metrics[0][$t_ptr] = $t_marker[$t]; + if ($f_summary) { + $t_metrics[1][$t_ptr] = 0; + $t_metrics[2][$t_ptr] = 0; + $t_metrics[3][$t_ptr] = 0; + foreach ( $t_view_status as $t_status => $t_label ) { + if ( isset( $t_data[$t][$t_status] ) ) { if ( $t_status < $t_resolved ) - $t_metrics[1][$t_ptr] += $t_data[$t][$t_status]; + $t_metrics[1][$t_ptr] += $t_data[$t][$t_status]; else if ( $t_status < $t_closed ) - $t_metrics[2][$t_ptr] += $t_data[$t][$t_status]; + $t_metrics[2][$t_ptr] += $t_data[$t][$t_status]; else - $t_metrics[3][$t_ptr] += $t_data[$t][$t_status]; - } - } else { - $i = 0; - foreach ( $t_status_arr as $t_status => $t_label ) { - $t_metrics[++$i][$t_ptr] = $t_data[$t][$t_status]; - } + $t_metrics[3][$t_ptr] += $t_data[$t][$t_status]; + } } - } + } else { + $i = 0; + foreach ( $t_view_status as $t_status => $t_label ) { + if ( isset( $t_data[$t][$t_status] ) ) + $t_metrics[++$i][$t_ptr] = $t_data[$t][$t_status]; + else + $t_metrics[++$i][$t_ptr] = 0; + } + } + if ( $f_show_as_table ) { + echo '<tr class="row-'.($t_ptr%2+1).'"><td>'.$t_ptr.' ('.db_date( $t_metrics[0][$t_ptr] ).')'.'</td>'; + for ( $i=1; $i<=$t_label_count; $i++ ) { + echo '<td>'.$t_metrics[$i][$t_ptr].'</td>'; + } + echo '</tr>'; + } + + } + if ($f_show_as_table) { + echo '</table>'; + html_body_end(); + html_end(); + } else { graph_bydate( $t_metrics, $t_labels, lang_get( 'by_category' ), $f_width, $f_width * $t_ar ); - } + } ?> \ No newline at end of file Modified: branches/BRANCH_1_1_0/mantisbt/bug_graph_page.php =================================================================== --- branches/BRANCH_1_1_0/mantisbt/bug_graph_page.php 2008-01-12 00:04:29 UTC (rev 4876) +++ branches/BRANCH_1_1_0/mantisbt/bug_graph_page.php 2008-01-12 01:41:35 UTC (rev 4877) @@ -46,9 +46,9 @@ $t_period->set_period_from_selector( 'interval' ); $t_types = array( 0 => lang_get( 'select' ), - 1 => lang_get( 'select_bystatus'), - 2 => lang_get( 'select_summbystatus'), - 3 => lang_get( 'select_bycat'), + 2 => lang_get( 'select_bystatus'), + 3 => lang_get( 'select_summbystatus'), + 4 => lang_get( 'select_bycat'), 6 => lang_get( 'select_both') ); @@ -78,9 +78,10 @@ </table> </form> <?php - if ( ( 0 != $f_type ) && ( $f_interval > 0 ) && ( gpc_get( 'show', '' ) != '') ) { // show selected info + // build the graphs if both an interval and graph type are selected + if ( ( 0 != $f_type ) && ( $f_interval > 0 ) && ( gpc_get( 'show', '' ) != '') ) { $t_width = config_get( 'graph_window_width' ); - $t_summary = ( $f_type % 2 ) == 0; + $t_summary = ( $f_type % 2 ) != 0; $t_body = (int)( $f_type / 2 ); $f_start = $t_period->get_start_formatted(); $f_end = $t_period->get_end_formatted(); Modified: branches/BRANCH_1_1_0/mantisbt/core/graph_api.php =================================================================== --- branches/BRANCH_1_1_0/mantisbt/core/graph_api.php 2008-01-12 00:04:29 UTC (rev 4876) +++ branches/BRANCH_1_1_0/mantisbt/core/graph_api.php 2008-01-12 01:41:35 UTC (rev 4877) @@ -351,7 +351,7 @@ $graph->SetScale('linlin'); $graph->SetMarginColor('white'); $graph->SetFrame(false); - $graph->title->Set( lang_get( 'by_date' ) ); + $graph->title->Set( $p_title . ' ' . lang_get( 'by_date' ) ); $graph->title->SetFont( $t_graph_font, FS_BOLD ); $graph->legend->Pos(0.01,0.05,'right','top'); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |