Mantis_summary_api.php_function summary_print_reporter_resolution

  1 # Print reporter / resolution report
  2 /**
  3  * 函数——总结,输出,报告人员,决议
  4  * 汉化By 江渤洋
  5  */
  6 function summary_print_reporter_resolution( $p_resolution_enum_string ) {
  7     $t_mantis_bug_table = db_get_table( 'mantis_bug_table' );
  8     $t_mantis_user_table = db_get_table( 'mantis_user_table' );
  9     $t_reporter_summary_limit = config_get( 'reporter_summary_limit' );
 10 
 11     $t_project_id = helper_get_current_project();
 12     $t_user_id = auth_get_current_user_id();
 13 
 14     # Get the resolution values ot use
 15     $c_res_s = MantisEnum::getValues( $p_resolution_enum_string );
 16     $enum_res_count = count( $c_res_s );
 17 
 18     # Checking if it's a per project statistic or all projects
 19     $specific_where = helper_project_specific_where( $t_project_id );
 20     if( ' 1<>1' == $specific_where ) {
 21         return;
 22     }
 23 
 24     # Get all of the bugs and split them up into an array
 25     $query = "SELECT COUNT(id) as bugcount, reporter_id, resolution
 26                 FROM $t_mantis_bug_table
 27                 WHERE $specific_where
 28                 GROUP BY reporter_id, resolution";
 29     $result = db_query_bound( $query );
 30 
 31     $t_reporter_res_arr = array();
 32     $t_reporter_bugcount_arr = array();
 33     $t_arr = db_fetch_array( $result );
 34     while( $t_arr ) {
 35         if( !isset( $t_reporter_res_arr[$t_arr['reporter_id']] ) ) {
 36             $t_reporter_res_arr[$t_arr['reporter_id']] = array();
 37             $t_reporter_bugcount_arr[$t_arr['reporter_id']] = 0;
 38         }
 39         if( !isset( $t_reporter_res_arr[$t_arr['reporter_id']][$t_arr['resolution']] ) ) {
 40             $t_reporter_res_arr[$t_arr['reporter_id']][$t_arr['resolution']] = 0;
 41         }
 42         $t_reporter_res_arr[$t_arr['reporter_id']][$t_arr['resolution']] += $t_arr['bugcount'];
 43         $t_reporter_bugcount_arr[$t_arr['reporter_id']] += $t_arr['bugcount'];
 44 
 45         $t_arr = db_fetch_array( $result );
 46     }
 47 
 48     # Sort our total bug count array so that the reporters with the highest number of bugs are listed first,
 49     arsort( $t_reporter_bugcount_arr );
 50 
 51     $t_row_count = 0;
 52 
 53     # We now have a multi dimensional array of users and resolutions, with the value of each resolution for each user
 54     foreach( $t_reporter_bugcount_arr as $t_reporter_id => $t_total_user_bugs ) {
 55 
 56         # Limit the number of reporters listed
 57         if( $t_row_count > $t_reporter_summary_limit ) {
 58             break;
 59         }
 60 
 61         # Only print reporters who have reported at least one bug. This helps
 62         # prevent divide by zeroes, showing reporters not on this project, and showing
 63         # users that aren't actually reporters...
 64         if( $t_total_user_bugs > 0 ) {
 65             $t_arr2 = $t_reporter_res_arr[$t_reporter_id];
 66 
 67             echo '<tr align="center" ' . helper_alternate_class( $t_row_count ) . '>';
 68             $t_row_count++;
 69             echo '<td>';
 70             echo string_display_line( user_get_name( $t_reporter_id ) );
 71             echo '</td>';
 72 
 73             # We need to track the percentage of bugs that are considered fix, as well as
 74             # those that aren't considered bugs to begin with (when looking at %age)
 75             $t_bugs_fixed = 0;
 76             $t_bugs_notbugs = 0;
 77             for( $j = 0;$j < $enum_res_count;$j++ ) {
 78                 $res_bug_count = 0;
 79 
 80                 if( isset( $t_arr2[$c_res_s[$j]] ) ) {
 81                     $res_bug_count = $t_arr2[$c_res_s[$j]];
 82                 }
 83 
 84                 echo '<td>';
 85                 if( 0 < $res_bug_count ) {
 86                     $t_bug_link = '<a class="subtle" href="' . config_get( 'bug_count_hyperlink_prefix' ) . '&amp;' . FILTER_PROPERTY_REPORTER_ID . '=' . $t_reporter_id;
 87                     $t_bug_link = $t_bug_link . '&amp;' . FILTER_PROPERTY_RESOLUTION_ID . '=' . $c_res_s[$j] . '">';
 88                     echo $t_bug_link . $res_bug_count . '</a>';
 89                 } else {
 90                     echo $res_bug_count;
 91                 }
 92                 echo '</td>';
 93                 echo"<br>";
 94 
 95               /*
 96                 if( $c_res_s[$j] >= config_get( 'bug_resolution_fixed_threshold' ) ) 
 97                 {
 98                     if ( $c_res_s[$j] < config_get( 'bug_resolution_not_fixed_threshold' ) ) 
 99                     {
100                         # Count bugs with a resolution between fixed and not fixed thresholds
101                         $t_bugs_fixed += $res_bug_count;
102                     } 
103                     else 
104                     {
105                         # Count bugs with a resolution above the not fixed threshold
106                             $t_bugs_notbugs += $res_bug_count;
107                     }
108                 }
109                 */
110                         
111                 #
112                 # BUG处理状况对照表
113                 # 
114                 # -----------------------------------------------------------
115                 # |__数字__|____中文_____|________英文________|__有效/无效__|
116                 # |   10   |   未处理    |        open        |     --      |
117                 # |   20   |   已修正    |        fixed       |     有      |
118                 # |   30   |  重新打开   |      reopened      |     有      |
119                 # |   40   |  无法重现   | unable to duplicate|     有      |
120                 # |   50   |  无法修复   |     not fixable    |     有      |
121                 # |   60   |  重复问题   |      duplicate     |     有      |
122                 # |   70   |  不是BUG    |      not a bug     |     无      |
123                 # |   80   |  稍后处理   |      suspended     |     有      |
124                 # |   90   | BUG不做处理 |      wont fix      |     有      |
125                 # -----------------------------------------------------------
126                 #
127                 # "未处理"的BUG,即不算有效,也不算无效。
128                 # "不是BUG"的BUG,为无效BUG。
129                 
130                 /* 
131                  * 报告员无效率
132                  * By Doug
133                  * 修改时间:2013-05-28 
134                  */
135                  
136                 //BUG处理状况对应的枚举值需大于等于20,即排除未处理的BUG。 
137                 if( $c_res_s[$j] >= 20)
138                 {
139                     //BUG处理状况不是"70-不是BUG",则记为有效BUG。否则为无效BUG。
140                     if( $c_res_s[$j]!= 70 )
141                     {
142                             $t_bugs_fixed += $res_bug_count;
143                     }
144                     else
145                     {
146                             //print_r($c_res_s[$j]);    ——测试输出的BUG类型
147                             $t_bugs_notbugs += $res_bug_count;
148                     }    
149                 }
150             }
151             /*
152               print_r("有效BUG数: ".$t_bugs_fixed."<br/>");
153                 
154                 print_r("<br/>无效BUG数: ".$t_bugs_notbugs."<br/>");
155 
156                 print_r("<br/>BUG总数: ".$t_total_user_bugs."<br/>");
157             */
158             
159             $t_percent_errors = 0;
160             if( $t_total_user_bugs > 0 ) {
161                 //BUG总数包括未处理的BUG
162                 $t_percent_errors = ( $t_bugs_notbugs / $t_total_user_bugs );
163             }
164             echo '<td>';
165             //输出BUG失效率
166             printf( '% 1.0f%%', ( $t_percent_errors * 100 ) );
167             echo '</td>';
168             echo '</tr>';
169         }
170     }
171 }

 

posted @ 2013-05-27 22:13  道格  阅读(149)  评论(0)    收藏  举报