function buildData()

in synergy/client/app/js/controllers.js [1194:1331]


        function buildData() {
            var arrObj = {};
            var knownSpecs = [];
            var _currentSuite;
            var _currentSpec;

            var totalTc = 0;
            var passedTc = 0;
            var failedTc = 0;
            var skippedTc = 0;
            var totalMins = 0;

            $scope.run.durations.forEach(function (x) {
                totalMins += x.duration;
            });

            var passedWithIssues = 0;
            var _users = [];
            var _allLabels = [];

            $scope.run.blobs.forEach(function (blob) {
                if (_users.indexOf(blob.user) < 0) {
                    _users.push(blob.user);
                }
                if (blob.label.length > 0 && _allLabels.indexOf(blob.label) < 0) {
                    _allLabels.push(blob.label);
                }

                if (knownSpecs.indexOf(blob.specification.id) < 0) {
                    knownSpecs.push(blob.specification.id);
                    arrObj["_" + blob.specification.id] = {
                        name: blob.specification.name,
                        id: blob.specification.id,
                        expanded: false,
                        label: blob.label,
                        version: blob.specification.version,
                        suites: {}
                    };
                }
                _currentSpec = arrObj["_" + blob.specification.id];
                // for each suite
                blob.specification.suites.forEach(function (suite) {

                    if (!_currentSpec.suites.hasOwnProperty("_" + suite.id)) {
                        _currentSpec.suites["_" + suite.id] = {
                            name: suite.name,
                            id: suite.id,
                            expanded: false,
                            testCases: {}
                        };
                    }

                    _currentSuite = _currentSpec.suites["_" + suite.id];

                    suite.testCases.forEach(function (tc) {
                        if (!_currentSuite.testCases.hasOwnProperty("_" + tc.id)) {
                            _currentSuite.testCases["_" + tc.id] = {
                                name: tc.name,
                                id: tc.id,
                                results: []
                            };
                        }
                        if (tc.finished === 1) {
                            totalTc++;
                            var _s = getResult(tc);
                            if (_s === "passed") {
                                passedTc++;
                            } else if (_s === "passed with issues") {
                                passedTc++;
                                passedWithIssues++;
                            } else if (_s === "failed") {
                                failedTc++;
                            } else if (_s === "skipped") {
                                skippedTc++;
                            }
                            _currentSuite.testCases["_" + tc.id].results.push({
                                result: _s,
                                visible: true,
                                issuesLbl: tc.issues.length > 1 ? "issues" : (tc.issues.length === 0 ? "" : tc.issues[0]),
                                link: "#/case/" + tc.id + "/suite/" + suite.id,
                                resultClass: _s.replace(/\s/g, "_"),
                                platform: blob.platform,
                                user: blob.user,
                                issues: tc.issues.length > 0 ? tc.issues : []
                            });
                        }

                    });
                });
            });


            var arr = [];
            var _x;
            var _y;
            var _suites;
            var _cases;
            for (var k in arrObj) {
                if (arrObj.hasOwnProperty(k)) {
                    _x = arrObj[k];
                    _suites = [];
                    for (var l in _x.suites) {
                        if (_x.suites.hasOwnProperty(l)) {

                            _y = _x.suites[l];
                            _cases = [];
                            for (var m in _y.testCases) {
                                if (_y.testCases.hasOwnProperty(m)) {
                                    _cases.push(_y.testCases[m]);
                                }
                            }
                            _y.testCases = _cases;
                            _suites.push(_y);
                        }
                    }
                    _x.suites = _suites;
                    arr.push(_x);
                }
            }

            var _pRateRound = Math.round(100 * 10 * passedTc / totalTc) / 10;
            var _fRateRound = Math.round(100 * 10 * failedTc / totalTc) / 10;
            var _pRateRound2 = Math.round(100 * 10 * passedWithIssues / totalTc) / 10;
            var _sRateRound = Math.round(10 * (100 - _pRateRound - _fRateRound - _pRateRound2)) / 10;

            var start = $scope.getDate($scope.run.start);
            var stop = $scope.getDate($scope.run.end);

            $scope.overview = {
                totalTc: totalTc,
                pRate: _pRateRound + "% passed, " + _pRateRound2 + "% passed with issues, " + _fRateRound + "% failed and " + _sRateRound + "% skipped",
                testers: _users.length,
                duration: getDuration(stop.getTime() - start.getTime()),
                time: totalMins > 59 ? Math.floor(totalMins / 60) + " hours and " + (totalMins % 60) + " minutes" : totalMins + " minutes"
            };
            $scope.specs = arr;
            $scope.labels = _allLabels;
        }