* 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
+4 -13
View File
@@ -103,13 +103,8 @@ class bug extends control
elseif($browseType == 'needconfirm') $bugs = $this->bug->getByNeedconfirm($productID, $projects, $orderBy, $pager);
elseif($browseType == 'bysearch') $bugs = $this->bug->getBySearch($productID, $projects, $queryID, $orderBy, $pager);
/* Process the sql, get the conditon partion, save it to session. Thus the report page can use the same condition. */
if($browseType != 'needconfirm')
{
$sql = explode('WHERE', $this->dao->get());
$sql = explode('ORDER', $sql[1]);
$this->session->set('bugReportCondition', $sql[0]);
}
/* Process the sql, get the conditon partion, save it to session. */
if($browseType != 'needconfirm') $this->loadModel('common')->saveQueryCondition($this->dao->get(), 'bug');
/* Get custom fields. */
$customFields = $this->cookie->bugFields != false ? $this->cookie->bugFields : $this->config->bug->list->defaultFields;
@@ -348,11 +343,6 @@ class bug extends control
$productID = $bug->product;
$productName = $this->products[$productID];
/* Get the previous and next bug. */
$tmpBugIDs = $this->dao->select('id')->from(TABLE_BUG)->where($this->session->bugReport)->fetchPairs('id');
$bugIDs = ',' . implode(',', $tmpBugIDs) . ',';
$this->view->preAndNext = $this->loadModel('common')->getPreAndNextObject('bug', $bugIDs, $bugID);
/* Header and positon. */
$this->view->header->title = $this->products[$productID] . $this->lang->colon . $this->lang->bug->view;
$this->view->position[] = html::a($this->createLink('bug', 'browse', "productID=$productID"), $productName);
@@ -366,6 +356,7 @@ class bug extends control
$this->view->users = $this->user->getPairs('noletter');
$this->view->actions = $this->action->getList('bug', $bugID);
$this->view->builds = $this->loadModel('build')->getProductBuildPairs($productID);
$this->view->preAndNext = $this->loadModel('common')->getPreAndNextObject('bug', $bugID);
$this->display();
}
@@ -850,7 +841,7 @@ class bug extends control
}
/* Get bugs. */
$bugs = $this->dao->select('*')->from(TABLE_BUG)->alias('t1')->where($this->session->bugReportCondition)->orderBy($orderBy)->fetchAll('id');
$bugs = $this->dao->select('*')->from(TABLE_BUG)->where($this->session->bugQueryCondition)->orderBy($orderBy)->fetchAll('id');
/* Get users, products and projects. */
$users = $this->loadModel('user')->getPairs('noletter');
+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;
}
/**
+1 -1
View File
@@ -47,7 +47,7 @@
}
if($preAndNext->next)
{
echo "<abbr id='next' title={$preAndNext->next->id}{$lang->colon}{$preAndNext->pre->title}>" . html::a($this->inLink('view', "storyID={$preAndNext->next->id}"), '>') . "</abbr>";
echo "<abbr id='next' title={$preAndNext->next->id}{$lang->colon}{$preAndNext->next->title}>" . html::a($this->inLink('view', "storyID={$preAndNext->next->id}"), '>') . "</abbr>";
}
?>
</div>
+5
View File
@@ -115,8 +115,13 @@ class build extends control
/* Set menu. */
$build = $this->build->getById((int)$buildID, true);
if(!$build) die(js::error($this->lang->notFound) . js::locate('back'));
$stories = $this->dao->select('*')->from(TABLE_STORY)->where('id')->in($build->stories)->fetchAll();
$this->loadModel('common')->saveQueryCondition($this->dao->get(), 'story');
$bugs = $this->dao->select('*')->from(TABLE_BUG)->where('id')->in($build->bugs)->fetchAll();
$this->loadModel('common')->saveQueryCondition($this->dao->get(), 'bug');
$this->loadModel('project')->setMenu($this->project->getPairs(), $build->project);
/* Assign. */
+3
View File
@@ -123,6 +123,9 @@ class product extends control
if($browseType == 'changedstory')$stories = $this->story->getByStatus($productID, 'changed', $orderBy, $pager);
if($browseType == 'closedstory') $stories = $this->story->getByStatus($productID, 'closed', $orderBy, $pager);
/* Process the sql, get the conditon partion, save it to session. */
$this->loadModel('common')->saveQueryCondition($this->dao->get(), 'story');
/* Build search form. */
$this->config->product->search['actionURL'] = $this->createLink('product', 'browse', "productID=$productID&browseType=bySearch&queryID=myQueryID");
$this->config->product->search['queryID'] = $queryID;
+5
View File
@@ -128,11 +128,16 @@ class release extends control
{
$this->loadModel('story');
$this->loadModel('bug');
$release = $this->release->getById((int)$releaseID, true);
if(!$release) die(js::error($this->lang->notFound) . js::locate('back'));
$stories = $this->dao->select('*')->from(TABLE_STORY)->where('id')->in($release->stories)->fetchAll();
$this->loadModel('common')->saveQueryCondition($this->dao->get(), 'story');
$bugs = $this->dao->select('*')->from(TABLE_BUG)->where('id')->in($release->bugs)->fetchAll();
$this->loadModel('common')->saveQueryCondition($this->dao->get(), 'bug');
$this->commonAction($release->product);
$this->view->header->title = $this->lang->release->view;
+2 -12
View File
@@ -626,7 +626,7 @@ class storyModel extends model
*/
public function getProductStories($productID = 0, $moduleIds = 0, $status = 'all', $orderBy = 'id_desc', $pager = null)
{
$stories = $this->dao->select('t1.*, t2.title as planTitle')
return $this->dao->select('t1.*, t2.title as planTitle')
->from(TABLE_STORY)->alias('t1')
->leftJoin(TABLE_PRODUCTPLAN)->alias('t2')->on('t1.plan = t2.id')
->where('t1.product')->in($productID)
@@ -634,10 +634,6 @@ class storyModel extends model
->beginIF($status != 'all')->andWhere('status')->in($status)->fi()
->andWhere('t1.deleted')->eq(0)
->orderBy($orderBy)->page($pager)->fetchAll();
$this->loadModel('common')->saveQueryCondition($this->dao->get(), 'story');
return $stories;
}
/**
@@ -753,7 +749,7 @@ class storyModel extends model
*/
public function getByField($productID, $fieldName, $fieldValue, $orderBy, $pager, $operator = 'equal')
{
$stories = $this->dao->select('t1.*, t2.title as planTitle')
return $this->dao->select('t1.*, t2.title as planTitle')
->from(TABLE_STORY)->alias('t1')
->leftJoin(TABLE_PRODUCTPLAN)->alias('t2')->on('t1.plan = t2.id')
->where('t1.product')->in($productID)
@@ -763,10 +759,6 @@ class storyModel extends model
->orderBy($orderBy)
->page($pager)
->fetchAll();
$this->loadModel('common')->saveQueryCondition($this->dao->get(), 'story');
return $stories;
}
/**
@@ -832,8 +824,6 @@ class storyModel extends model
->page($pager)
->fetchAll('id');
$this->loadModel('common')->saveQueryCondition($this->dao->get(), 'story');
if(!$tmpStories) return array();
/* Get plans. */