<commit_before>(function(exports) {
    'use strict';

    var bgoControllers = angular.module('bgoControllers', []);

    var taskNames = ['resolve', 'build', 'smoketest', 'integrationtest', 'applicationstest'];

    var ROOT = '/continuous/buildmaster/';

    var YMD_SERIAL_VERSION_RE = /^(\d+)(\d\d)(\d\d)\.(\d+)$/;

    function relpathToVersion(relpath) {
	var parts = relpath.split('/');
	parts.shift(); // Remove builds/
	return parts[0] + parts[1] + parts[2] + '.' + parts[3];
    };

    function versionToRelpath(version) {
	var match = YMD_SERIAL_VERSION_RE.exec(version);
	return match[1] + '/' + match[2] + '/' +
	    match[3] + '/' + match[4];
    };

    bgoControllers.controller('ContinuousStatusCtrl', function($scope, $http) {
        $http.get(ROOT + 'results/tasks/build/build/meta.json').success(function(data) {
            $scope.status = data.success ? 'good' : 'bad';
            $scope.buildVersion = relpathToVersion(data.buildPath);
        });
    });

    function renderApps($http, path, callback) {
        $http.get(ROOT + path + '/applicationstest/apps.json').success(function(data) {
            var apps = data['apps'];

            // Older builds use a different scheme for the
            // applicationstest; just ignore them.
            if (!apps.forEach)
                return;

            apps.forEach(function(app) {
                // Mangle the data a bit

                app.name = app.id; /* XXX */
                app.status = (app.state == "success") ? 'good' : 'bad';

                // XXX -- this should probably be in the template
                if (app.icon)
                    app.icon = ROOT + app.icon;
                else
                    app.icon = '/images/app-generic.png';

                app.screenshot = ROOT + app.screenshot;
            });
	    callback(apps);
        });
    }

    bgoControllers.controller('ContinuousBuildViewCtrl', function($scope, $http, $routeParams) {
        var buildVersion = $routeParams.buildVersion;
        $scope.buildVersion = buildVersion;

	var buildPath = versionToRelpath(buildVersion);
        var buildRoot = ROOT + 'builds/' + buildPath + '/';

        var tasks = [];
        taskNames.forEach(function(taskName) {
            $http.get(buildRoot + taskName + '/meta.json').success(function(data) {
                // Mangle the data a bit so we can render it better
                data['name'] = taskName;
		data['version'] = relpathToVersion(data['buildPath']);
                tasks.push(data);
            }).error(function(data, status, headers, config) {
		data = {};
		data['name'] = taskName;
		data['status'] = '(not found for this build)';
                tasks.push(data);
	    });
        });
        $scope.tasks = tasks;

	renderApps($http, 'builds/' + buildPath, function(apps) {
            $scope.apps = apps;
	});
    });

    function compareTaskData(a, b) {
	var ai = taskNames.indexOf(a['name']);
	var bi = taskNames.indexOf(b['name']);
	return ai - bi;
    }

    bgoControllers.controller('ContinuousHomeCtrl', function($scope, $http) {
        var builds = [];

        $http.get(ROOT + 'autobuilder-status.json').success(function(status) {
            var text;
            if (status.running.length > 0)
                text = 'Running: ' + status.running.join(' ') + '; load=' + status.systemLoad[0];
            else
                text = 'Idle, awaiting commits';

            $scope.runningState = text;
        });

        var completedTasks = [];
        taskNames.forEach(function(taskName) {
	    var href = ROOT + 'results/tasks/' + taskName + '/' + taskName;
            $http.get(href + '/meta.json').success(function(data) {
                // Mangle the data a bit so we can render it better
                data['name'] = taskName;
		data['version'] = relpathToVersion(data['buildPath']);
		data['href'] = href;
                completedTasks.push(data);
		completedTasks.sort(compareTaskData);
		$scope[taskName] = data;
            }).error(function(data, status, headers, config) {
		data = {};
		data['name'] = taskName;
		data['status'] = '(none completed)';
                completedTasks.push(data);
		completedTasks.sort(compareTaskData);<commit_msg>b.g.o: "resolve" task version for href<commit_after>(function(exports) {
    'use strict';

    var bgoControllers = angular.module('bgoControllers', []);

    var taskNames = ['resolve', 'build', 'smoketest', 'integrationtest', 'applicationstest'];

    var ROOT = '/continuous/buildmaster/';

    var YMD_SERIAL_VERSION_RE = /^(\d+)(\d\d)(\d\d)\.(\d+)$/;

    function relpathToVersion(relpath) {
	var parts = relpath.split('/');
	parts.shift(); // Remove builds/
	return parts[0] + parts[1] + parts[2] + '.' + parts[3];
    };

    function versionToRelpath(version) {
	var match = YMD_SERIAL_VERSION_RE.exec(version);
	return match[1] + '/' + match[2] + '/' +
	    match[3] + '/' + match[4];
    };

    bgoControllers.controller('ContinuousStatusCtrl', function($scope, $http) {
        $http.get(ROOT + 'results/tasks/build/build/meta.json').success(function(data) {
            $scope.status = data.success ? 'good' : 'bad';
            $scope.buildVersion = relpathToVersion(data.buildPath);
        });
    });

    function renderApps($http, path, callback) {
        $http.get(ROOT + path + '/applicationstest/apps.json').success(function(data) {
            var apps = data['apps'];

            // Older builds use a different scheme for the
            // applicationstest; just ignore them.
            if (!apps.forEach)
                return;

            apps.forEach(function(app) {
                // Mangle the data a bit

                app.name = app.id; /* XXX */
                app.status = (app.state == "success") ? 'good' : 'bad';

                // XXX -- this should probably be in the template
                if (app.icon)
                    app.icon = ROOT + app.icon;
                else
                    app.icon = '/images/app-generic.png';

                app.screenshot = ROOT + app.screenshot;
            });
	    callback(apps);
        });
    }

    bgoControllers.controller('ContinuousBuildViewCtrl', function($scope, $http, $routeParams) {
        var buildVersion = $routeParams.buildVersion;
        $scope.buildVersion = buildVersion;

	var buildPath = versionToRelpath(buildVersion);
        var buildRoot = ROOT + 'builds/' + buildPath + '/';

        var tasks = [];
        taskNames.forEach(function(taskName) {
            $http.get(buildRoot + taskName + '/meta.json').success(function(data) {
                // Mangle the data a bit so we can render it better
                data['name'] = taskName;
		data['version'] = relpathToVersion(data['buildPath']);
                tasks.push(data);
            }).error(function(data, status, headers, config) {
		data = {};
		data['name'] = taskName;
		data['status'] = '(not found for this build)';
                tasks.push(data);
	    });
        });
        $scope.tasks = tasks;

	renderApps($http, 'builds/' + buildPath, function(apps) {
            $scope.apps = apps;
	});
    });

    function compareTaskData(a, b) {
	var ai = taskNames.indexOf(a['name']);
	var bi = taskNames.indexOf(b['name']);
	return ai - bi;
    }

    bgoControllers.controller('ContinuousHomeCtrl', function($scope, $http) {
        var builds = [];

        $http.get(ROOT + 'autobuilder-status.json').success(function(status) {
            var text;
            if (status.running.length > 0)
                text = 'Running: ' + status.running.join(' ') + '; load=' + status.systemLoad[0];
            else
                text = 'Idle, awaiting commits';

            $scope.runningState = text;
        });

        var completedTasks = [];
        taskNames.forEach(function(taskName) {
	    var href = ROOT + 'results/tasks/' + taskName + '/' + taskName;
            $http.get(href + '/meta.json').success(function(data) {
                // Mangle the data a bit so we can render it better
                data['name'] = taskName;
		data['version'] = relpathToVersion(data['buildPath']);
		data['href'] = ROOT + data['path'];
                completedTasks.push(data);
		completedTasks.sort(compareTaskData);
		$scope[taskName] = data;
            }).error(function(data, status, headers, config) {
		data = {};
		data['name'] = taskName;
		data['status'] = '(none completed)';
                completedTasks.push(data);
		completedTasks.sort(compareTaskData);
{'fraction_non_alphanumeric': 0.15477031802120142, 'fraction_numerical': 0.002355712603062426, 'mean_word_length': 2.218726307808946, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4107860', 'n_tokens_mistral': 2602, 'n_tokens_neox': 2479, 'n_words': 511}