forked from rage-your-dream/baibaiba
/
class.db.Bug.php
205 lines (196 loc) · 5.67 KB
/
class.db.Bug.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
<?php
require_once "class.DBConn.php";
require_once "config.php";
class BugDB extends DBConn{
/**
* 查询上周新增和未关闭BUG
* LW lastweek
*/
public function selectBugLW(){
$conn=parent::getConn(DB_DSN_REDMINE);
$w=date('w')-1;
// $sql="SELECT a.ProjectName AS `name`,COUNT(a.ProjectName) AS `count1`,b.`count2`FROM bug a LEFT JOIN (SELECT ProjectName AS `name`,COUNT(ProjectName) AS `count2` FROM bug WHERE StatusId IN(1,2,9,22) AND CreateTime > SUBDATE(CURDATE(),DATE_FORMAT(CURDATE(),'%w')-1) GROUP BY ProjectName)b ON a.ProjectName = b.`name` WHERE a.CreateTime > SUBDATE(CURDATE(),DATE_FORMAT(CURDATE(),'%w')-1) GROUP BY a.ProjectName;";
$sql="CALL selectWeekBugTable();";
try{
$st=$conn->prepare($sql);
$st->execute();
$row=$st->fetchALL();
$conn=Null;
}catch(PDOException $e){
echo "failure:".$e->getMessage();
return false;
}
return $row;
}
/**
* 查询上周新增BUG
* LW lastweek
*/
public function selectNewBugLW(){
$conn=parent::getConn(DB_DSN_REDMINE);
$sql="CALL selectNewBugLW();";
//echo $sql;
try{
$st=$conn->prepare($sql);
$st->execute();
$row=$st->fetchALL();
$conn=Null;
}catch(PDOException $e){
echo "failure:".$e->getMessage();
return false;
}
return $row;
}
/**
* 查询上周遗留BUG 经过修改调整为本周,sql语句也做了变动
* LW lastweek
*/
//select ProjectName,count(ProjectName) from bug where DATE_SUB(CURDATE(), INTERVAL 7 DAY) <= date(CreateTime) and (StatusId='1' or StatusId='2' or StatusId='9') group by ProjectName;
public function selectLeaveBugLW(){
$conn=parent::getConn(DB_DSN_REDMINE);
$sql="CALL selectLeaveBugLW();";
//echo $sql;
try{
$st=$conn->prepare($sql);
$st->execute();
$row=$st->fetchALL();
$conn=Null;
}catch(PDOException $e){
echo "failure:".$e->getMessage();
return false;
}
return $row;
}
/**
* 按周查询开放BUG
*/
//select week(CreateTime,3),count(*) from bug where year(CreateTime)='2014' and (StatusId = '1' OR bug.StatusId = '2' OR bug.StatusId = '9') group by week(CreateTime,3)
public function selectOpenBugByWeek(){
$conn=parent::getConn(DB_DSN_PMS);
$sql="SELECT projectname AS week_num,COUNT(bugid) AS `count` FROM bug WHERE createtime > '2014-01-01' AND statusid IN (1,2,5,8,9,22) GROUP BY projectname ORDER BY `count` DESC limit 21;";
//echo $sql;
try{
$st=$conn->prepare($sql);
$st->execute();
$row=$st->fetchALL();
$conn=Null;
}catch(PDOException $e){
echo "failure:".$e->getMessage();
return false;
}
return $row;
}
/**
* 查询个项目开放BUG
*/
//select ProjectName,count(ProjectName) from bug where StatusId='1' or StatusId='2' or StatusId='9' group by ProjectName;
public function selectOpenBug(){
$conn=parent::getConn(DB_DSN_PMS);
$sql="select ProjectName as name,count(ProjectName) as count from bug where StatusId='1' or StatusId='2' or StatusId='9'or StatusId='22' group by ProjectName order by count DESC;";
//echo $sql;
try{
$st=$conn->prepare($sql);
$st->execute();
$row=$st->fetchALL();
$conn=Null;
}catch(PDOException $e){
echo "failure:".$e->getMessage();
return false;
}
return $row;
}
/**
* 查询个项目关闭BUG
*/
//select ProjectName,count(ProjectName) from bug where StatusId='5' or StatusId='8' group by ProjectName;
public function selectClosedBug(){
$conn=parent::getConn(DB_DSN_PMS);
$sql="select ProjectName as name,count(ProjectName) as count from bug where StatusId='5' or StatusId='8' group by ProjectName;";
//echo $sql;
try{
$st=$conn->prepare($sql);
$st->execute();
$row=$st->fetchALL();
$conn=Null;
}catch(PDOException $e){
echo "failure:".$e->getMessage();
return false;
}
return $row;
}
/**
* 查询本周新增bug(按照星期日期,项目)
*/
//select ProjectName,count(ProjectName) from bug where StatusId='1' or StatusId='2' or StatusId='9' group by ProjectName;
public function selectWeekBugTrend(){
$conn=parent::getConn(DB_DSN_REDMINE);
$sql="CALL selectWeekBugTrend();";
//echo $sql;
try{
$st=$conn->prepare($sql);
$st->execute();
$row=$st->fetchALL();
$conn=Null;
}catch(PDOException $e){
echo "failure:".$e->getMessage();
return false;
}
return $row;
}
/**
* 查询本周新增bug(按照状态,指派)
*/
//select ProjectName,count(ProjectName) from bug where StatusId='1' or StatusId='2' or StatusId='9' group by ProjectName;
public function selectWeekBugDistributeDim1(){
$conn=parent::getConn(DB_DSN_REDMINE);
$sql="CALL selectWeekBugDistributeDim1();";
//echo $sql;
try{
$st=$conn->prepare($sql);
$st->execute();
$row=$st->fetchALL();
$conn=Null;
}catch(PDOException $e){
echo "failure:".$e->getMessage();
return false;
}
return $row;
}
public function selectWeekBugDistributeDim2(){
$conn=parent::getConn(DB_DSN_REDMINE);
$sql="CALL selectWeekBugDistributeDim2();";
//echo $sql;
try{
$st=$conn->prepare($sql);
$st->execute();
$row=$st->fetchALL();
$conn=Null;
}catch(PDOException $e){
echo "failure:".$e->getMessage();
return false;
}
return $row;
}
/*
* 查询本周发现缺陷总数
*/
public function selectWeekTotalBug(){
$conn=parent::getConn(DB_DSN_REDMINE);
$sql="CALL selectWeekTotalBug();";
//echo $sql;
try{
$st=$conn->prepare($sql);
$st->execute();
$row=$st->fetchALL();
$conn=Null;
}catch(PDOException $e){
echo "failure:".$e->getMessage();
return false;
}
return $row[0][0];
}
}
//$db=new BugDB();
//$r=$db->selectWeekBugDistributeDim1();
//print_r($r);
?>