<commit_before>(function () {
    angular
        .module('dpDataSelection')
        .factory('dataSelectionApi', dataSelectionApiFactory);

    dataSelectionApiFactory.$inject = ['dpDataSelectionConfig', 'api'];

    function dataSelectionApiFactory (dpDataSelectionConfig, api) {
        return {
            query: query
        };

        function query (dataset, activeFilters, page) {
            var searchParams = angular.merge(
                {
                    page: page
                },
                activeFilters
            );

            return api.getByUrl(dpDataSelectionConfig[dataset].ENDPOINT_PREVIEW, searchParams).then(function (data) {
                return {
                    number_of_pages: data.page_count,
                    filters: formatFilters(dataset, data.aggs_list),
                    tableData: formatTableData(dataset, data.object_list)
                };
            });
        }

        function formatFilters (dataset, rawData) {
            var formattedFilters = angular.copy(dpDataSelectionConfig[dataset].FILTERS);

            return formattedFilters.filter(function (filter) {
                //Only show the filters that are returned by the API
                return angular.isObject(rawData[filter.slug]);
            }).map(function (filter) {
                //Add all the available options for each filter
                filter.options = rawData[filter.slug].buckets.map(function (option) {
                    return {
                        label: option.key,
                        count: option.doc_count
                    };
                });

                //Note: filter.options is limited to 100 results
                filter.numberOfOptions = rawData[filter.slug].doc_count;

                return filter;
            });
        }

        function formatTableData (dataset, rawData) {
            var tableHead,
                tableBody = [];

            tableHead = dpDataSelectionConfig[dataset].FIELDS.map(function (field) {
                return field.label;
            });

            tableBody = rawData.map(function (rawDataRow) {
                var detailEndpoint;

                detailEndpoint = dpDataSelectionConfig[dataset].ENDPOINT_DETAIL;
                detailEndpoint += rawDataRow[dpDataSelectionConfig[dataset].PRIMARY_KEY];
                detailEndpoint += '/';

                return {
                    detailEndpoint: detailEndpoint,
                    fields: dpDataSelectionConfig[dataset].FIELDS.map(function (field) {
                        return rawDataRow[field.slug];<commit_msg>Removed unused code (empty array)<commit_after>(function () {
    angular
        .module('dpDataSelection')
        .factory('dataSelectionApi', dataSelectionApiFactory);

    dataSelectionApiFactory.$inject = ['dpDataSelectionConfig', 'api'];

    function dataSelectionApiFactory (dpDataSelectionConfig, api) {
        return {
            query: query
        };

        function query (dataset, activeFilters, page) {
            var searchParams = angular.merge(
                {
                    page: page
                },
                activeFilters
            );

            return api.getByUrl(dpDataSelectionConfig[dataset].ENDPOINT_PREVIEW, searchParams).then(function (data) {
                return {
                    number_of_pages: data.page_count,
                    filters: formatFilters(dataset, data.aggs_list),
                    tableData: formatTableData(dataset, data.object_list)
                };
            });
        }

        function formatFilters (dataset, rawData) {
            var formattedFilters = angular.copy(dpDataSelectionConfig[dataset].FILTERS);

            return formattedFilters.filter(function (filter) {
                //Only show the filters that are returned by the API
                return angular.isObject(rawData[filter.slug]);
            }).map(function (filter) {
                //Add all the available options for each filter
                filter.options = rawData[filter.slug].buckets.map(function (option) {
                    return {
                        label: option.key,
                        count: option.doc_count
                    };
                });

                //Note: filter.options is limited to 100 results
                filter.numberOfOptions = rawData[filter.slug].doc_count;

                return filter;
            });
        }

        function formatTableData (dataset, rawData) {
            var tableHead,
                tableBody;

            tableHead = dpDataSelectionConfig[dataset].FIELDS.map(function (field) {
                return field.label;
            });

            tableBody = rawData.map(function (rawDataRow) {
                var detailEndpoint;

                detailEndpoint = dpDataSelectionConfig[dataset].ENDPOINT_DETAIL;
                detailEndpoint += rawDataRow[dpDataSelectionConfig[dataset].PRIMARY_KEY];
                detailEndpoint += '/';

                return {
                    detailEndpoint: detailEndpoint,
                    fields: dpDataSelectionConfig[dataset].FIELDS.map(function (field) {
                        return rawDataRow[field.slug];
{'fraction_non_alphanumeric': 0.08477805296246904, 'fraction_numerical': 0.001143074871404077, 'mean_word_length': 1.6002971768202081, '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': '7390252', 'n_tokens_mistral': 1261, 'n_tokens_neox': 1175, 'n_words': 243}