* adjust for qa role annualdata.

This commit is contained in:
wangyidong
2019-12-25 11:27:30 +08:00
parent 9a30b4a9d4
commit fab5c4a9d8
5 changed files with 87 additions and 33 deletions
+1 -1
View File
@@ -20,7 +20,7 @@ $config->report->annualData['dev']['block4'] = array('title' => 'devData', 'data
$config->report->annualData['dev']['block5'] = array('title' => 'devStatistics', 'data' => array('effortMonth'));
$config->report->annualData['qa']['block1'] = array('title' => 'baseInfo', 'data' => array('logins', 'actions', 'foundBugs', 'createdCases'));
$config->report->annualData['qa']['block2'] = array('title' => 'projectOverview', 'data' => array('doneProject', 'doingProject', 'suspendProject'));
$config->report->annualData['qa']['block2'] = array('title' => 'qaOverview', 'data' => array());
$config->report->annualData['qa']['block3'] = array('title' => '', 'data' => array('projects'));
$config->report->annualData['qa']['block4'] = array('title' => 'qaData', 'data' => array('bugPri', 'casePri'));
$config->report->annualData['qa']['block5'] = array('title' => 'qaStatistics', 'data' => array('bugMonth', 'caseMonth'));
+10 -10
View File
@@ -260,7 +260,7 @@ class report extends control
$products = $this->report->getUserYearProducts($account, $year);
$data['involvedProducts'] = count($products);
$planGroups = $this->report->getPlansByProducts($products, $year);
$planGroups = $this->report->getPlansByProducts($products, $account, $year);
$planCount = 0;
foreach($planGroups as $plans) $planCount += $plans;
$data['createdPlans'] = $planCount;
@@ -272,7 +272,7 @@ class report extends control
$data['storyStage'] = $storyInfo['stage'];
$data['storyMonth'] = $storyInfo['month'];
$storyGroups = $this->report->getStoriesByProducts($products, $year);
$storyGroups = $this->report->getStoriesByProducts($products, $account, $year);
foreach($products as $productID => $product)
{
$product->plans = zget($planGroups, $productID, 0);
@@ -288,7 +288,7 @@ class report extends control
$data['efforts'] = $efforts->count;
$data['consumed'] = $efforts->consumed;
$projects = $this->report->getUserYearProjects($account, $year, $role);
$projects = $this->report->getUserYearProjects($account, $year);
$projectStat = $this->report->getStatByProjects($projects);
$tasks = $this->report->getUserYearFinishedTasks($account, $year);
@@ -297,7 +297,7 @@ class report extends control
$data['resolvedBugPri'] = $bugs['pri'];
$data['effortMonth'] = $this->report->getEffort4Month($account, $year);;
$stories = $this->report->getFinishedStoryByProjects($projects, $year);
$stories = $this->report->getFinishedStoryByProjects($projects, $account, $year);
$tasks = $this->report->getFinishedTaskByProjects($projects, $account, $year);
$bugs = $this->report->getResolvedBugByProjects($projects, $account, $year);
foreach($projects as $projectID => $project)
@@ -323,14 +323,14 @@ class report extends control
$data['casePri'] = $caseInfo['pri'];
$data['caseMonth'] = $caseInfo['month'];
$projects = $this->report->getUserYearProjects($account, $year, $role);
$projectStat = $this->report->getStatByProjects($projects);
$products = $this->report->getUserYearProducts4QA($account, $year);
$productStat = $this->report->getBugStatByProducts($products, $account, $year);
$bugs = $this->report->getCreatedBugByProjects($projects, $year);
foreach($projects as $projectID => $project) $project->bugs = zget($bugs, $projectID, 0);
$bugs = $this->report->getCreatedBugByProducts($products, $account, $year);
foreach($products as $productID => $product) $product->bugs = zget($bugs, $productID, 0);
$data['projects'] = $projects;
$data['projectStat'] = $projectStat;
$data['products'] = $products;
$data['productStat'] = $productStat;
}
$firstAction = $this->dao->select('*')->from(TABLE_ACTION)->orderBy('id')->limit(1)->fetch();
+2 -1
View File
@@ -116,6 +116,7 @@ $lang->report->annualData->createdPlans = "累计创建计划数";
$lang->report->annualData->createdStories = "累计创建需求数";
$lang->report->annualData->productOverview = "产品创建的需求数及占比";
$lang->report->annualData->qaOverview = "产品创建的Bug数及占比";
$lang->report->annualData->projectOverview = "参与项目概览";
$lang->report->annualData->doneProject = "已完成的项目";
$lang->report->annualData->doingProject = "正在进行的项目";
@@ -142,7 +143,7 @@ $lang->report->annualData->poData = "所创建的需求数对应的优
$lang->report->annualData->totalStoryPri = "创建需求优先级分布";
$lang->report->annualData->totalStoryStage = "创建需求阶段分布";
$lang->report->annualData->qaStatistics = "完成任务与解决bug工时统计";
$lang->report->annualData->qaStatistics = "完成任务与解决Bug工时统计";
$lang->report->annualData->poStatistics = "月创建需求数";
$lang->report->annualData->devStatistics = "月完成任务累计工时";
+61 -17
View File
@@ -647,29 +647,31 @@ class reportModel extends model
return $products;
}
public function getPlansByProducts($products, $year)
public function getPlansByProducts($products, $account, $year)
{
return $this->dao->select('t1.product, count(DISTINCT t1.id) as plans')->from(TABLE_PRODUCTPLAN)->alias('t1')
->leftJoin(TABLE_ACTION)->alias('t2')->on("t1.id=t2.objectID and t2.objectType='productplan'")
->where('t1.deleted')->eq(0)
->andWhere('t1.product')->in(array_keys($products))
->andWhere('LEFT(t2.date, 4)')->eq($year)
->andWhere('t2.actor')->eq($account)
->andWhere('t2.action')->eq('opened')
->groupBy('t1.product')
->fetchPairs('product', 'plans');
}
public function getStoriesByProducts($products, $year)
public function getStoriesByProducts($products, $account, $year)
{
return $this->dao->select('product, count(*) as stories')->from(TABLE_STORY)
->where('deleted')->eq(0)
->andWhere('product')->in(array_keys($products))
->andWhere('LEFT(openedDate, 4)')->eq($year)
->andWhere('openedBy')->eq($account)
->groupBy('product')
->fetchPairs('product', 'stories');
}
public function getUserYearProjects($account, $year, $role = 'dev')
public function getUserYearProjects($account, $year)
{
$projects = $this->dao->select('id,name,status')->from(TABLE_PROJECT)->where('deleted')->eq(0)
->andWhere('LEFT(begin, 4)', true)->eq($year)
@@ -682,32 +684,26 @@ class reportModel extends model
->orWhere('RD')->eq($account)
->markRight(1)
->fetchAll('id');
$teamProjects = $this->dao->select('*')->from(TABLE_TEAM)->where('type')->eq('project')->andWhere('account')->eq($account)->andWhere('LEFT(`join`, 4)')->eq($year)->fetchPairs('root', 'root');
$taskProjects = array();
if($role == 'dev') $taskProjects = $this->dao->select('project')->from(TABLE_TASK)->where('finishedBy')->eq($account)->andWhere('LEFT(finishedDate, 4)')->eq($year)->andWhere('deleted')->eq(0)->fetchPairs('project', 'project');
$taskProjects = $this->dao->select('project')->from(TABLE_TASK)->where('finishedBy')->eq($account)->andWhere('LEFT(finishedDate, 4)')->eq($year)->andWhere('deleted')->eq(0)->fetchPairs('project', 'project');
$projects += $this->dao->select('id,name,status')->from(TABLE_PROJECT)->where('deleted')->eq(0)
->andWhere('id')->in($teamProjects + $taskProjects)
->fetchAll('id');
return $projects;
}
public function getCreatedBugByProjects($projects, $year)
{
return $this->dao->select('project, count(*) as bugs')->from(TABLE_BUG)
->where('deleted')->eq(0)
->andWhere('project')->in(array_keys($projects))
->andWhere('LEFT(openedDate, 4)')->eq($year)
->groupBy('project')
->fetchPairs('project', 'bugs');
}
public function getFinishedStoryByProjects($projects, $year)
public function getFinishedStoryByProjects($projects, $account, $year)
{
return $this->dao->select('t1.project, count(DISTINCT t1.story) as stories')->from(TABLE_PROJECTSTORY)->alias('t1')
->leftJoin(TABLE_STORY)->alias('t2')->on('t1.story=t2.id')
->leftJoin(TABLE_TASK)->alias('t3')->on('t1.story=t3.story')
->where('t2.deleted')->eq(0)
->andWhere('t3.deleted')->eq(0)
->andWhere('t1.project')->in(array_keys($projects))
->andWhere('LEFT(t2.closedDate, 4)')->eq($year)
->andWhere('LEFT(t3.finishedDate, 4)')->eq($year)
->andWhere('t3.finishedBy')->eq($account)
->groupBy('t1.project')
->fetchPairs('project', 'stories');
}
@@ -791,6 +787,54 @@ class reportModel extends model
}
return $months;
}
public function getUserYearProducts4QA($account, $year)
{
$bugProducts = $this->dao->select('product')->from(TABLE_BUG)->where('openedBy')->eq($account)->andWhere('LEFT(openedDate, 4)')->eq($year)->andWhere('deleted')->eq(0)->fetchPairs('product', 'product');
$caseProducts = $this->dao->select('product')->from(TABLE_CASE)->where('openedBy')->eq($account)->andWhere('LEFT(openedDate, 4)')->eq($year)->andWhere('deleted')->eq(0)->fetchPairs('product', 'product');
$products = $this->dao->select('id,name,status')->from(TABLE_PRODUCT)
->where('deleted')->eq(0)
->andWhere('id')->in($bugProducts + $caseProducts)
->fetchAll('id');
return $products;
}
public function getBugStatByProducts($products, $account, $year)
{
$allBugs = $this->dao->select('product, count(*) as count')->from(TABLE_BUG)->where('deleted')->eq(0)
->andWhere('product')->in(array_keys($products))
->andWhere('LEFT(openedDate, 4)')->eq($year)
->groupBy('product')
->fetchPairs('product', 'count');
$mineBugs = $this->dao->select('product, count(*) as count')->from(TABLE_BUG)->where('deleted')->eq(0)
->andWhere('product')->in(array_keys($products))
->andWhere('openedBy')->eq($account)
->andWhere('LEFT(openedDate, 4)')->eq($year)
->groupBy('product')
->fetchPairs('product', 'count');
$productStat = array();
foreach($products as $productID => $product)
{
$productStat[$productID]['name'] = $product->name;
$productStat[$productID]['count'] = zget($allBugs, $productID, 0);
$productStat[$productID]['mine'] = zget($mineBugs, $productID, 0);
}
return $productStat;
}
public function getCreatedBugByProducts($products, $account, $year)
{
return $this->dao->select('product, count(*) as bugs')->from(TABLE_BUG)
->where('deleted')->eq(0)
->andWhere('product')->in(array_keys($products))
->andWhere('LEFT(openedDate, 4)')->eq($year)
->andWhere('openedBy')->eq($account)
->groupBy('product')
->fetchPairs('product', 'bugs');
}
}
/**
+13 -4
View File
@@ -69,7 +69,7 @@
</section>
<div id='toolbar'>
<?php echo html::select('year', $years, $year, "class='form-control'");?>
<button type='button' class='btn btn-primary' id='exportBtn'><i class='icon icon-export'></i></button>
<button type='button' class='btn btn-primary' id='exportBtn' title='<?php echo $lang->export;?>'><i class='icon icon-share'></i></button>
<a id='imageDownloadBtn' class='hidden' download='annual_data.png'></a>
</div>
</main>
@@ -96,7 +96,7 @@ var annualData =
elseif($blockKey == 'block2')
{
echo "unit: '" . $lang->report->annualData->unit . "',";
if($role == 'qa' or $role == 'dev')
if($role == 'dev')
{
$count = $data['projectStat']['count'];
$blockData[] = array('title' => $lang->report->annualData->doneProject, 'value' => $data['projectStat']['done'], 'percent' => (empty($count) ? 0 : round($data['projectStat']['done'] / $count, 4) * 100 . '%'));
@@ -113,6 +113,15 @@ var annualData =
}
echo "data: " . json_encode($blockData);
}
elseif($role == 'qa')
{
foreach($data['productStat'] as $productStat)
{
$count = $productStat['count'];
$blockData[] = array('title' => $productStat['name'], 'value' => (int)$productStat['mine'], 'percent' => (empty($count) ? '0' : round($productStat['mine'] / $count, 3) * 100 . '%'));
}
echo "data: " . json_encode($blockData);
}
}
elseif($blockKey == 'block3')
{
@@ -137,10 +146,10 @@ var annualData =
}
elseif($role == 'qa')
{
$cols[] = array('title' => $lang->report->annualData->projectName, 'width' => 'auto', 'align' => 'left');
$cols[] = array('title' => $lang->report->annualData->productName, 'width' => 'auto', 'align' => 'left');
$cols[] = array('title' => $lang->report->annualData->foundBug, 'width' => '80', 'align' => 'center');
foreach($data['projects'] as $project) $rows[] = array($project->name, $project->bugs);
foreach($data['products'] as $product) $rows[] = array($product->name, $product->bugs);
}
echo "cols: " . json_encode($cols) . ',';