// We have faced a performance block due to an environment with
// 700 Builds and 1300 Test Cases on Test Plan
// This created a block on NOT RUN QUERY, but anyway will produce an enormous and
// unmanageable matrix on screen
//
// New way to process:
// ACTIVE Build Qty > 20 => Ask user to select builds he/she wants to use
// Cell Qty = (ACTIVE Build Qty x Test Cases on Test plan) > 2000 => said user I'm sorry
//
if ($gui->activeBuildsQty <= $gui->matrixCfg->buildQtyLimit || $args->do_action == 'result') {
    setUpBuilds($args, $gui);
    $tpl = $templateCfg->default_template;
    $opt = null;
    $buildSet = array('buildSet' => $args->builds->idSet);
    $opt = array('getExecutionNotes' => true, 'getTester' => true, 'getUserAssignment' => true, 'output' => 'cumulative', 'getExecutionTimestamp' => true, 'getExecutionDuration' => true);
    $execStatus = $metricsMgr->getExecStatusMatrixFlat($args->tplan_id, $buildSet, $opt);
    $metrics = $execStatus['metrics'];
    $latestExecution = $execStatus['latestExec'];
    // Every Test suite a row on matrix to display will be created
    // One matrix will be created for every platform that has testcases
    $tcols = array('tsuite', 'tcase', 'version');
    if ($gui->show_platforms) {
        $tcols[] = 'platform';
    }
    $tcols[] = 'priority';
    $cols = array_flip($tcols);
    $args->cols = $cols;
    if (!is_null($execStatus['metrics'])) {
        buildSpreadsheetData($db, $args, $gui, $execStatus, $labels);
    }
    createSpreadsheet($gui, $args);