* Refactory setting of the bugQueryCondition session.

* code for task#633.
This commit is contained in:
chencongzhi520@gmail.com
2012-06-13 06:59:30 +00:00
parent 5f2478b992
commit 0de924a08a
7 changed files with 45 additions and 43 deletions
+25 -17
View File
@@ -403,11 +403,15 @@ class bugModel extends model
*/
public function getProjectBugs($projectID, $orderBy = 'id_desc', $pager = null, $build = 0)
{
return $this->dao->select('*')->from(TABLE_BUG)
$bugs = $this->dao->select('*')->from(TABLE_BUG)
->where('project')->eq((int)$projectID)
->beginIF($build != 0)->andWhere('openedBuild')->eq($build)->fi()
->andWhere('deleted')->eq(0)
->orderBy($orderBy)->page($pager)->fetchAll();
$this->loadModel('common')->saveQueryCondition($this->dao->get(), 'bug');
return $bugs;
}
/**
@@ -471,7 +475,7 @@ class bugModel extends model
*/
public function getDataOfBugsPerProject()
{
$datas = $this->dao->select('project as name, count(project) as value')->from(TABLE_BUG)->where($this->session->bugReportCondition)->groupBy('project')->orderBy('value DESC')->fetchAll('name');
$datas = $this->dao->select('project as name, count(project) as value')->from(TABLE_BUG)->where($this->session->bugQueryCondition)->groupBy('project')->orderBy('value DESC')->fetchAll('name');
if(!$datas) return array();
$projects = $this->loadModel('project')->getPairs();
foreach($datas as $projectID => $data) $data->name = isset($projects[$projectID]) ? $projects[$projectID] : $this->lang->report->undefined;
@@ -486,7 +490,7 @@ class bugModel extends model
*/
public function getDataOfBugsPerBuild()
{
$datas = $this->dao->select('openedBuild as name, count(openedBuild) as value')->from(TABLE_BUG)->where($this->session->bugReportCondition)->groupBy('openedBuild')->orderBy('value DESC')->fetchAll('name');
$datas = $this->dao->select('openedBuild as name, count(openedBuild) as value')->from(TABLE_BUG)->where($this->session->bugQueryCondition)->groupBy('openedBuild')->orderBy('value DESC')->fetchAll('name');
if(!$datas) return array();
$builds = $this->loadModel('build')->getProductBuildPairs($this->session->product);
@@ -527,7 +531,7 @@ class bugModel extends model
*/
public function getDataOfBugsPerModule()
{
$datas = $this->dao->select('module as name, count(module) as value')->from(TABLE_BUG)->where($this->session->bugReportCondition)->groupBy('module')->orderBy('value DESC')->fetchAll('name');
$datas = $this->dao->select('module as name, count(module) as value')->from(TABLE_BUG)->where($this->session->bugQueryCondition)->groupBy('module')->orderBy('value DESC')->fetchAll('name');
if(!$datas) return array();
$modules = $this->dao->select('id, name')->from(TABLE_MODULE)->where('id')->in(array_keys($datas))->fetchPairs();
foreach($datas as $moduleID => $data) $data->name = isset($modules[$moduleID]) ? $modules[$moduleID] : '/';
@@ -542,7 +546,7 @@ class bugModel extends model
*/
public function getDataOfOpenedBugsPerDay()
{
return $this->dao->select('DATE_FORMAT(openedDate, "%Y-%m-%d") AS name, COUNT(*) AS value')->from(TABLE_BUG)->where($this->session->bugReportCondition)->groupBy('name')->orderBy('openedDate')->fetchAll();
return $this->dao->select('DATE_FORMAT(openedDate, "%Y-%m-%d") AS name, COUNT(*) AS value')->from(TABLE_BUG)->where($this->session->bugQueryCondition)->groupBy('name')->orderBy('openedDate')->fetchAll();
}
/**
@@ -554,7 +558,7 @@ class bugModel extends model
public function getDataOfResolvedBugsPerDay()
{
return $this->dao->select('DATE_FORMAT(resolvedDate, "%Y-%m-%d") AS name, COUNT(*) AS value')->from(TABLE_BUG)
->where($this->session->bugReportCondition)->groupBy('name')
->where($this->session->bugQueryCondition)->groupBy('name')
->having('name != 0000-00-00')
->orderBy('resolvedDate')
->fetchAll();
@@ -569,7 +573,7 @@ class bugModel extends model
public function getDataOfClosedBugsPerDay()
{
return $this->dao->select('DATE_FORMAT(closedDate, "%Y-%m-%d") AS name, COUNT(*) AS value')->from(TABLE_BUG)
->where($this->session->bugReportCondition)->groupBy('name')
->where($this->session->bugQueryCondition)->groupBy('name')
->having('name != 0000-00-00')
->orderBy('closedDate')->fetchAll();
}
@@ -582,7 +586,7 @@ class bugModel extends model
*/
public function getDataOfOpenedBugsPerUser()
{
$datas = $this->dao->select('openedBy AS name, COUNT(*) AS value')->from(TABLE_BUG)->where($this->session->bugReportCondition)->groupBy('name')->orderBy('value DESC')->fetchAll('name');
$datas = $this->dao->select('openedBy AS name, COUNT(*) AS value')->from(TABLE_BUG)->where($this->session->bugQueryCondition)->groupBy('name')->orderBy('value DESC')->fetchAll('name');
if(!$datas) return array();
if(!isset($this->users)) $this->users = $this->loadModel('user')->getPairs('noletter');
foreach($datas as $account => $data) if(isset($this->users[$account])) $data->name = $this->users[$account];
@@ -598,7 +602,7 @@ class bugModel extends model
public function getDataOfResolvedBugsPerUser()
{
$datas = $this->dao->select('resolvedBy AS name, COUNT(*) AS value')
->from(TABLE_BUG)->where($this->session->bugReportCondition)
->from(TABLE_BUG)->where($this->session->bugQueryCondition)
->andWhere('resolvedBy')->ne('')
->groupBy('name')
->orderBy('value DESC')->fetchAll('name');
@@ -618,7 +622,7 @@ class bugModel extends model
{
$datas = $this->dao->select('closedBy AS name, COUNT(*) AS value')
->from(TABLE_BUG)
->where($this->session->bugReportCondition)
->where($this->session->bugQueryCondition)
->andWhere('closedBy')->ne('')
->groupBy('name')
->orderBy('value DESC')->fetchAll('name');
@@ -636,7 +640,7 @@ class bugModel extends model
*/
public function getDataOfBugsPerSeverity()
{
$datas = $this->dao->select('severity AS name, COUNT(*) AS value')->from(TABLE_BUG)->where($this->session->bugReportCondition)->groupBy('name')->orderBy('value DESC')->fetchAll('name');
$datas = $this->dao->select('severity AS name, COUNT(*) AS value')->from(TABLE_BUG)->where($this->session->bugQueryCondition)->groupBy('name')->orderBy('value DESC')->fetchAll('name');
if(!$datas) return array();
foreach($datas as $severity => $data) if(isset($this->lang->bug->severityList[$severity])) $data->name = $this->lang->bug->severityList[$severity];
return $datas;
@@ -652,7 +656,7 @@ class bugModel extends model
{
$datas = $this->dao->select('resolution AS name, COUNT(*) AS value')
->from(TABLE_BUG)
->where($this->session->bugReportCondition)
->where($this->session->bugQueryCondition)
->andWhere('resolution')->ne('')
->groupBy('name')->orderBy('value DESC')
->fetchAll('name');
@@ -669,7 +673,7 @@ class bugModel extends model
*/
public function getDataOfBugsPerStatus()
{
$datas = $this->dao->select('status AS name, COUNT(*) AS value')->from(TABLE_BUG)->where($this->session->bugReportCondition)->groupBy('name')->orderBy('value DESC')->fetchAll('name');
$datas = $this->dao->select('status AS name, COUNT(*) AS value')->from(TABLE_BUG)->where($this->session->bugQueryCondition)->groupBy('name')->orderBy('value DESC')->fetchAll('name');
if(!$datas) return array();
foreach($datas as $status => $data) if(isset($this->lang->bug->statusList[$status])) $data->name = $this->lang->bug->statusList[$status];
return $datas;
@@ -683,7 +687,7 @@ class bugModel extends model
*/
public function getDataOfBugsPerActivatedCount()
{
$datas = $this->dao->select('activatedCount AS name, COUNT(*) AS value')->from(TABLE_BUG)->where($this->session->bugReportCondition)->groupBy('name')->orderBy('value DESC')->fetchAll('name');
$datas = $this->dao->select('activatedCount AS name, COUNT(*) AS value')->from(TABLE_BUG)->where($this->session->bugQueryCondition)->groupBy('name')->orderBy('value DESC')->fetchAll('name');
if(!$datas) return array();
foreach($datas as $data) $data->name = $this->lang->bug->report->bugsPerActivatedCount->graph->xAxisName . ':' . $data->name;
return $datas;
@@ -697,7 +701,7 @@ class bugModel extends model
*/
public function getDataOfBugsPerType()
{
$datas = $this->dao->select('type AS name, COUNT(*) AS value')->from(TABLE_BUG)->where($this->session->bugReportCondition)->groupBy('name')->orderBy('value DESC')->fetchAll('name');
$datas = $this->dao->select('type AS name, COUNT(*) AS value')->from(TABLE_BUG)->where($this->session->bugQueryCondition)->groupBy('name')->orderBy('value DESC')->fetchAll('name');
if(!$datas) return array();
foreach($datas as $type => $data) if(isset($this->lang->bug->typeList[$type])) $data->name = $this->lang->bug->typeList[$type];
return $datas;
@@ -712,7 +716,7 @@ class bugModel extends model
public function getDataOfBugsPerAssignedTo()
{
$datas = $this->dao->select('assignedTo AS name, COUNT(*) AS value')
->from(TABLE_BUG)->where($this->session->bugReportCondition)
->from(TABLE_BUG)->where($this->session->bugQueryCondition)
->groupBy('name')
->orderBy('value DESC')->fetchAll('name');
if(!$datas) return array();
@@ -807,10 +811,14 @@ class bugModel extends model
*/
public function getAllBugs($productID, $projects, $orderBy, $pager)
{
return $this->dao->select('*')->from(TABLE_BUG)->where('product')->eq($productID)
$bugs = $this->dao->select('*')->from(TABLE_BUG)->where('product')->eq($productID)
->andWhere('project')->in(array_keys($projects))
->andWhere('deleted')->eq(0)
->orderBy($orderBy)->page($pager)->fetchAll();
$this->loadModel('common')->saveQueryCondition($this->dao->get(), 'bug');
return $bugs;
}
/**