<commit_before>angular.module('ot.service.buildfilter', [
    'ot.service.core',
    'ot.service.form'
])
    .service('otBuildFilterService', function (ot, $q, $http, otFormService) {
        var self = {};

        /**
         * Loads the list of available filters from two sources:
         * - the server filters for the current user (if logged)
         * - the local filters
         *
         * The remote filters have priority over the local ones.
         *
         * Additionally, fetches the available filter forms for the branch.
         */
        self.loadFilters = function (branch) {
            var d = $q.defer();
            // Result to define
            var filters = {
            };
            // Loads the local filters for this branch
            var store = self.getStoreForBranch(branch.id);
            // Loads the remote filters & the filter forms for this branch
            ot.call($http.get(branch._buildFilters)).then(function (buildFilters) {
                // List of forms
                filters.buildFilterForms = buildFilters.buildFilterForms;
                // Combine local & remote filters
                angular.forEach(store, function (filter) {
                    filter.local = true;
                });
                angular.forEach(buildFilters.buildFilterResources, function (buildFilterResource) {
                    store[buildFilterResource.name] = buildFilterResource;
                });
                // Gets the values for the store
                filters.store = [];
                angular.forEach(store, function (value) {
                    filters.store.push(value);
                });
                // OK
                d.resolve(filters);
            });
            // OK
            return d.promise;
        };

        /**
         * Creating a new build filter
         * @param config.branchId ID of the branch
         * @param config.buildFilterForm Build filter form
         * @return Promise with the created filter
         */
        self.createBuildFilter = function (config) {
            return otFormService.display({
                title: "New filter",
                form: config.buildFilterForm.form,
                submit: function (filterData) {
                    // Stores locally the filter data if named
                    if (filterData.name) {
                        self.storeForBranch(config, filterData);
                    }
                    // Stores locally as current
                    self.storeCurrent(config.branchId, filterData);
                    // OK
                    return true;
                }
            });
        };

        self.getCurrentFilter = function (branchId) {<commit_msg>Build filter: sets the type for an anonymous filter<commit_after>angular.module('ot.service.buildfilter', [
    'ot.service.core',
    'ot.service.form'
])
    .service('otBuildFilterService', function (ot, $q, $http, otFormService) {
        var self = {};

        /**
         * Loads the list of available filters from two sources:
         * - the server filters for the current user (if logged)
         * - the local filters
         *
         * The remote filters have priority over the local ones.
         *
         * Additionally, fetches the available filter forms for the branch.
         */
        self.loadFilters = function (branch) {
            var d = $q.defer();
            // Result to define
            var filters = {
            };
            // Loads the local filters for this branch
            var store = self.getStoreForBranch(branch.id);
            // Loads the remote filters & the filter forms for this branch
            ot.call($http.get(branch._buildFilters)).then(function (buildFilters) {
                // List of forms
                filters.buildFilterForms = buildFilters.buildFilterForms;
                // Combine local & remote filters
                angular.forEach(store, function (filter) {
                    filter.local = true;
                });
                angular.forEach(buildFilters.buildFilterResources, function (buildFilterResource) {
                    store[buildFilterResource.name] = buildFilterResource;
                });
                // Gets the values for the store
                filters.store = [];
                angular.forEach(store, function (value) {
                    filters.store.push(value);
                });
                // OK
                d.resolve(filters);
            });
            // OK
            return d.promise;
        };

        /**
         * Creating a new build filter
         * @param config.branchId ID of the branch
         * @param config.buildFilterForm Build filter form
         * @return Promise with the created filter
         */
        self.createBuildFilter = function (config) {
            return otFormService.display({
                title: "New filter",
                form: config.buildFilterForm.form,
                submit: function (filterData) {
                    filterData.type = config.buildFilterForm.type;
                    // Stores locally the filter data if named
                    if (filterData.name) {
                        self.storeForBranch(config, filterData);
                    }
                    // Stores locally as current
                    self.storeCurrent(config.branchId, filterData);
                    // OK
                    return true;
                }
            });
        };

        self.getCurrentFilter = function (branchId) {
{'fraction_non_alphanumeric': 0.08714362560516406, 'fraction_numerical': 0.0, 'mean_word_length': 1.3705907352316191, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '4817516', 'n_tokens_mistral': 1302, 'n_tokens_neox': 1246, 'n_words': 362}