<commit_before>(function(window, angular) {'use strict';
    var app = angular.module('fields', ['services.config']);

    app.controller('FieldsController', ['$http', '$q', '$rootScope', 'configuration', function($http, $q, $rootScope, configuration) {
        var _this = this;

        $rootScope.fieldsCtrl = this;

        this.datasetTypesFields = {};
        this.fields = [];

        $rootScope.$on('datasetType.selected', function(event, selectedDatasetType) {
            var fieldsRequest = configuration.ckanInstance + '/api/3/action/scheming_dataset_schema_show?callback=JSON_CALLBACK&type=',
                fieldsCallback = function(data) {
                    var type = data.result.dataset_type,
                        fields = data.result.dataset_fields,
                        fieldsLength = fields.length,
                        result = {},
                        languages = data.result.form_languages,
                        languagesLength = languages.length,
                        f, field, l, fieldObj;

                    for (f = 0; f < fieldsLength; f += 1) {
                        field = fields[f];
                        fieldObj = {type: field.schema_field_type};

                        if (field.schema_field_type === 'fluent' || (field.preset && field.preset.indexOf('fluent') !== -1)) {
                            for (l = 0; l < languagesLength; l += 1) {
                                result[field.field_name + '_' + languages[l]] = fieldObj;
                            }
                        } else {
                            result[field.field_name] = fieldObj;
                        }
                    }

                    _this.datasetTypesFields[type] = result;
                    addFields(type);
                },
                addFields = function(type) {
                    $.extend(newFields, _this.datasetTypesFields[type]);
                },
                promises = [],
                newFields = {},
                o, type, p;

            for (o = 0; o < selectedDatasetType.length; o += 1) {
                type = selectedDatasetType[o];

                if (!_this.datasetTypesFields[type]) {
                    p = $http.jsonp(fieldsRequest + type, {cache: true});
                    p.success(fieldsCallback);
                    promises.push(p);
                } else {
                    addFields(type);
                }
            }

            $q.all(promises)
                .then(function() {
                    _this.fields = Object.keys(newFields);
                    _this.fieldsDef = newFields;
                });
        });
    }]);
})(window, angular);<commit_msg>Fixed the fields no longer being sorted<commit_after>(function(window, angular) {'use strict';
    var app = angular.module('fields', ['services.config']);

    app.controller('FieldsController', ['$http', '$q', '$rootScope', 'configuration', function($http, $q, $rootScope, configuration) {
        var _this = this;

        $rootScope.fieldsCtrl = this;

        this.datasetTypesFields = {};
        this.fields = [];

        $rootScope.$on('datasetType.selected', function(event, selectedDatasetType) {
            var fieldsRequest = configuration.ckanInstance + '/api/3/action/scheming_dataset_schema_show?callback=JSON_CALLBACK&type=',
                fieldsCallback = function(data) {
                    var type = data.result.dataset_type,
                        fields = data.result.dataset_fields,
                        fieldsLength = fields.length,
                        result = {},
                        languages = data.result.form_languages,
                        languagesLength = languages.length,
                        f, field, l, fieldObj;

                    for (f = 0; f < fieldsLength; f += 1) {
                        field = fields[f];
                        fieldObj = {type: field.schema_field_type};

                        if (field.schema_field_type === 'fluent' || (field.preset && field.preset.indexOf('fluent') !== -1)) {
                            for (l = 0; l < languagesLength; l += 1) {
                                result[field.field_name + '_' + languages[l]] = fieldObj;
                            }
                        } else {
                            result[field.field_name] = fieldObj;
                        }
                    }

                    _this.datasetTypesFields[type] = result;
                    addFields(type);
                },
                addFields = function(type) {
                    $.extend(newFields, _this.datasetTypesFields[type]);
                },
                promises = [],
                newFields = {},
                o, type, p;

            for (o = 0; o < selectedDatasetType.length; o += 1) {
                type = selectedDatasetType[o];

                if (!_this.datasetTypesFields[type]) {
                    p = $http.jsonp(fieldsRequest + type, {cache: true});
                    p.success(fieldsCallback);
                    promises.push(p);
                } else {
                    addFields(type);
                }
            }

            $q.all(promises)
                .then(function() {
                    _this.fields = Object.keys(newFields).sort();
                    _this.fieldsDef = newFields;
                });
        });
    }]);
})(window, angular);
{'fraction_non_alphanumeric': 0.11809277397893181, 'fraction_numerical': 0.0029569395675475884, 'mean_word_length': 1.2874049027895182, 'pattern_counts': {'":': 0, '<': 9, '<?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': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1500430', 'n_tokens_mistral': 1379, 'n_tokens_neox': 1284, 'n_words': 245}