* Revise the process of generating data for the data table on the product view page.
This commit is contained in:
@@ -18,10 +18,112 @@ $fnGenerateCols = function()
|
||||
return $this->loadModel('datatable') ->getSetting('program');
|
||||
};
|
||||
|
||||
$totalStories = 0;
|
||||
$hasProduct = false;
|
||||
$linesCount = 0;
|
||||
$data = array();
|
||||
/* Closure for generating program row data. */
|
||||
$fnGenerateProgramRowData = function($programID, $program) use ($config, $users)
|
||||
{
|
||||
if(!isset($program['programName']) || $config->systemMode != 'ALM') return null;
|
||||
|
||||
/* ALM mode with more data. */
|
||||
$totalStories = $program['finishClosedStories'] + $program['unclosedStories'];
|
||||
$pmName = '';
|
||||
if(!empty($program['programPM']))
|
||||
{
|
||||
$programPM = $program['programPM'];
|
||||
$userName = zget($users, $programPM);
|
||||
$pmName = $userName;
|
||||
}
|
||||
|
||||
$item = new stdClass();
|
||||
$item->type = 'program';
|
||||
$item->id = 'program-' . $programID;
|
||||
$item->parent = '';
|
||||
$item->name = $program['programName'];
|
||||
$item->PM = $pmName;
|
||||
$item->createdDate = '';
|
||||
$item->createdBy = '';
|
||||
$item->totalUnclosedStories = $program['unclosedStories'];
|
||||
$item->totalStories = $totalStories;
|
||||
$item->closedStoryRate = ($totalStories == 0 ? 0 : round($program['finishClosedStories'] / $totalStories, 3) * 100);
|
||||
$item->totalPlans = $program['plans'];
|
||||
$item->totalProjects = rand(0, 100);
|
||||
$item->totalExecutions = 0;
|
||||
$item->testCaseCoverage = $program['coverage'];
|
||||
$item->totalActivatedBugs = 0;
|
||||
$item->totalBugs = 0;
|
||||
$item->fixedRate = $item->totalBugs == 0 ? 0 : round($program['fixedBugs'] / $item->totalBugs, 3) * 100;
|
||||
$item->totalReleases = $program['releases'];
|
||||
$item->latestReleaseDate = '';
|
||||
$item->latestRelease = '';
|
||||
|
||||
return $item;
|
||||
};
|
||||
|
||||
/* Closure for generating product line row data. */
|
||||
$fnGenerateLineRowData = function($programID, $lineID, $line) use ($config, &$linesCount)
|
||||
{
|
||||
if(!isset($line['lineName']) || !isset($line['products']) || !is_array($line['products']) || $config->systemMode != 'ALM') return null;
|
||||
|
||||
/* ALM mode with Product Line. */
|
||||
$totalStories = (isset($line['finishClosedStories']) ? $line['finishClosedStories'] : 0) + (isset($line['unclosedStories']) ? $line['unclosedStories'] : 0);
|
||||
$linesCount++;
|
||||
|
||||
$item = new stdClass();
|
||||
$item->type = 'productLine';
|
||||
$item->id = 'productLine-' . $lineID;
|
||||
$item->parent = 'program-' . $programID;
|
||||
$item->name = $line['lineName'];
|
||||
$item->PM = '';
|
||||
$item->createdDate = '';
|
||||
$item->createdBy = '';
|
||||
$item->totalUnclosedStories = $line['unclosedStories'];
|
||||
$item->totalStories = $totalStories;
|
||||
$item->closedStoryRate = ($totalStories == 0 ? 0 : round((isset($line['finishClosedStories']) ? $line['finishClosedStories'] : 0) / $totalStories, 3) * 100);
|
||||
$item->totalPlans = $line['plans'];
|
||||
$item->totalProjects = rand(0, 100);
|
||||
$item->totalExecutions = 0;
|
||||
$item->testCaseCoverage = $line['coverage'];
|
||||
$item->totalActivatedBugs = 0;
|
||||
$item->totalBugs = 0;
|
||||
$item->fixedRate = !empty($item->totalBugs) ? round($line['fixedBugs'] / $item->totalBugs, 3) * 100 : 0;
|
||||
$item->totalReleases = isset($line['releases']) ? $line['releases'] : 0;
|
||||
$item->latestReleaseDate = '';
|
||||
$item->latestRelease = '';
|
||||
|
||||
return $item;
|
||||
};
|
||||
|
||||
/* Closure for generating product row data. */
|
||||
$fnGenerateProductRowData = function($lineID, $product) use ($users)
|
||||
{
|
||||
$totalStories = $product->stories['finishClosed'] + $product->stories['unclosed'];
|
||||
|
||||
$item = new stdClass();
|
||||
$item->type = 'product';
|
||||
$item->id = $product->id;
|
||||
$item->parent = $product->line ? "productLine-$lineID" : ($product->program ? "program-$product->program" : '');
|
||||
$item->name = $product->name;
|
||||
$item->PM = !empty($product->PO) ? zget($users, $product->PO) : '';
|
||||
$item->createdDate = $product->createdDate;
|
||||
$item->createdBy = $product->createdBy;
|
||||
$item->totalUnclosedStories = $product->stories['unclosed'];
|
||||
$item->totalStories = $totalStories;
|
||||
$item->closedStoryRate = empty($totalStories) ? 0 : round($product->stories['finishClosed'] / $totalStories, 3) * 100;
|
||||
$item->totalPlans = $product->plans;
|
||||
$item->totalProjects = rand(0, 100);
|
||||
$item->totalExecutions = $product->executions;
|
||||
$item->testCaseCoverage = $product->coverage;
|
||||
$item->totalActivatedBugs = $product->activeBugs;
|
||||
$item->totalBugs = $product->bugs;
|
||||
$item->fixedRate = empty($item->totalBugs) ? 0 : round($product->fixedBugs / $item->totalBugs, 3) * 100;
|
||||
$item->totalReleases = $product->releases;
|
||||
$item->latestReleaseDate = $product->latestReleaseDate;
|
||||
$item->latestRelease = $product->latestRelease;
|
||||
|
||||
return $item;
|
||||
};
|
||||
|
||||
$linesCount = 0;
|
||||
$data = array();
|
||||
foreach($productStructure as $programID => $program)
|
||||
{
|
||||
if(isset($programLines[$programID]))
|
||||
@@ -37,118 +139,62 @@ foreach($productStructure as $programID => $program)
|
||||
}
|
||||
}
|
||||
|
||||
/* ALM mode with more data. */
|
||||
if(isset($program['programName']) && $config->systemMode == 'ALM')
|
||||
{
|
||||
$totalStories = $program['finishClosedStories'] + $program['unclosedStories'];
|
||||
$pmName = '';
|
||||
if(!empty($program['programPM']))
|
||||
{
|
||||
$programPM = $program['programPM'];
|
||||
$userName = zget($users, $programPM);
|
||||
$pmname = $userName;
|
||||
}
|
||||
|
||||
$item = new stdClass();
|
||||
$item->type = 'program';
|
||||
$item->id = 'program-' . $programID;
|
||||
$item->parent = '';
|
||||
$item->name = $program['programName'];
|
||||
$item->PM = $pmName;
|
||||
$item->createdDate = '';
|
||||
$item->createdBy = '';
|
||||
$item->totalUnclosedStories = $program['unclosedStories'];
|
||||
$item->totalStories = $totalStories;
|
||||
$item->closedStoryRate = ($totalStories == 0 ? 0 : round($program['finishClosedStories'] / $totalStories, 3) * 100);
|
||||
$item->totalPlans = $program['plans'];
|
||||
$item->totalProjects = rand(0, 100);
|
||||
$item->totalExecutions = rand(0, 100);
|
||||
$item->testCaseCoverage = rand(0, 100);
|
||||
$item->totalActivatedBugs = $program['activeStories'];
|
||||
$item->totalBugs = $program['unResolvedBugs'] + $program['fixedBugs'];
|
||||
$item->fixedRate = $item->totalBugs == 0 ? 0 : round($program['fixedBugs'] / $item->totalBugs, 3) * 100;
|
||||
$item->totalReleases = $program['releases'];
|
||||
$item->latestReleaseDate = '';
|
||||
$item->latestRelease = '';
|
||||
|
||||
$data[] = $item;
|
||||
}
|
||||
|
||||
$totalExecutions = 0;
|
||||
$totalBugs = 0;
|
||||
$totalActiveBugs = 0;
|
||||
foreach($program as $lineID => $line)
|
||||
{
|
||||
/* ALM mode with Product Line. */
|
||||
if(isset($line['lineName']) && isset($line['products']) && is_array($line['products']) && $config->systemMode == 'ALM')
|
||||
{
|
||||
$totalStories = (isset($line['finishClosedStories']) ? $line['finishClosedStories'] : 0) + (isset($line['unclosedStories']) ? $line['unclosedStories'] : 0);
|
||||
$linesCount++;
|
||||
|
||||
$item = new stdClass();
|
||||
$item->type = 'productLine';
|
||||
$item->id = 'productLine-' . $lineID;
|
||||
$item->parent = 'program-' . $programID;
|
||||
$item->name = $line['lineName'];
|
||||
$item->PM = '';
|
||||
$item->createdDate = '';
|
||||
$item->createdBy = '';
|
||||
$item->totalUnclosedStories = $line['unclosedStories'];
|
||||
$item->totalStories = $totalStories;
|
||||
$item->closedStoryRate = ($totalStories == 0 ? 0 : round((isset($line['finishClosedStories']) ? $line['finishClosedStories'] : 0) / $totalStories, 3) * 100);
|
||||
$item->totalPlans = $line['plans'];
|
||||
$item->totalProjects = rand(0, 100);
|
||||
$item->totalExecutions = rand(0, 100);
|
||||
$item->testCaseCoverage = rand(0, 100);
|
||||
$item->totalActivatedBugs = $line['activeStories'];
|
||||
$item->totalBugs = $line['unResolvedBugs'] + $line['fixedBugs'];
|
||||
$item->fixedRate = !empty($item->totalBugs) ? round($line['fixedBugs'] / $item->totalBugs, 3) * 100 : 0;
|
||||
$item->totalReleases = isset($line['releases']) ? $line['releases'] : 0;
|
||||
$item->latestReleaseDate = '';
|
||||
$item->latestRelease = '';
|
||||
|
||||
$data[] = $item;
|
||||
}
|
||||
|
||||
/* Products of Product Line. */
|
||||
$totalProductExecutions = 0;
|
||||
$totalProductBugs = 0;
|
||||
$totalProductActiveBugs = 0;
|
||||
if(isset($line['products']) && is_array($line['products']))
|
||||
{
|
||||
/* Generate product row data. */
|
||||
foreach($line['products'] as $productID => $product)
|
||||
{
|
||||
$hasProduct = true;
|
||||
$totalStories = $product->stories['finishClosed'] + $product->stories['unclosed'];
|
||||
$totalBugs = $product->unResolved + $product->fixedBugs;
|
||||
$productRow = $fnGenerateProductRowData($lineID, $product);
|
||||
if(!empty($productRow))
|
||||
{
|
||||
$totalProductExecutions += $productRow->totalExecutions;
|
||||
$totalProductBugs += $productRow->totalBugs;
|
||||
$totalProductActiveBugs += $productRow->totalActivatedBugs;
|
||||
|
||||
$item = new stdClass();
|
||||
$item->type = 'product';
|
||||
$item->id = $product->id;
|
||||
$item->parent = $product->line ? "productLine-$lineID" : ($product->program ? "program-$product->program" : '');
|
||||
$item->name = $product->name;
|
||||
$item->PM = !empty($product->PO) ? zget($users, $product->PO) : '';
|
||||
$item->createdDate = $product->createdDate;
|
||||
$item->createdBy = $product->createdBy;
|
||||
$item->totalUnclosedStories = $product->stories['unclosed'];
|
||||
$item->totalStories = $totalStories;
|
||||
$item->closedStoryRate = empty($totalStories) ? 0 : round($product->stories['finishClosed'] / $totalStories, 3) * 100;
|
||||
$item->totalPlans = $product->plans;
|
||||
$item->totalProjects = rand(0, 100);
|
||||
$item->totalExecutions = rand(0, 100);
|
||||
$item->testCaseCoverage = rand(0, 100);
|
||||
$item->totalActivatedBugs = $product->stories['active'];
|
||||
$item->totalBugs = $totalBugs;
|
||||
$item->fixedRate = empty($totalBugs) ? 0 : round($product->fixedBugs / $totalBugs, 3) * 100;
|
||||
$item->totalReleases = $product->releases;
|
||||
$item->latestReleaseDate = '';
|
||||
$item->latestRelease = '';
|
||||
|
||||
$data[] = $item;
|
||||
$data[] = $productRow;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Generate product line row data. */
|
||||
$lineRow = $fnGenerateLineRowData($programID, $lineID, $line);
|
||||
if(!empty($lineRow))
|
||||
{
|
||||
$lineRow->totalExecutions = $totalProductExecutions;
|
||||
$lineRow->totalBugs = $totalProductBugs;
|
||||
$lineRow->totalActivatedBugs = $totalProductActiveBugs;
|
||||
|
||||
$data[] = $lineRow;
|
||||
}
|
||||
|
||||
$totalExecutions += $totalProductExecutions;
|
||||
$totalBugs += $totalProductBugs;
|
||||
$totalActiveBugs += $totalProductActiveBugs;
|
||||
}
|
||||
|
||||
/* Generate program row data. */
|
||||
$programRow = $fnGenerateProgramRowData($programID, $program);
|
||||
if(!empty($programRow))
|
||||
{
|
||||
$programRow->totalExecutions = $totalExecutions;
|
||||
$programRow->totalBugs = $totalBugs;
|
||||
$programRow->totalActivatedBugs = $totalActiveBugs;
|
||||
|
||||
$data[] = $programRow;
|
||||
}
|
||||
}
|
||||
|
||||
$summary = sprintf($lang->product->lineSummary, $linesCount, count($productStats));
|
||||
jsVar('summary', $summary);
|
||||
|
||||
set::title($lang->program->productView);
|
||||
|
||||
/* Layout. */
|
||||
|
||||
featureBar
|
||||
|
||||
Reference in New Issue
Block a user