<commit_before>/**
 * @name FilesService
 */

import angular from 'angular';
import FileSaver from 'file-saver';

export class FilesService {
    constructor($http, EnvironmentService) {
        'ngInject';

        this.$http = $http;
        this.URL = `${EnvironmentService.getCurrent().BASE_URL}/file`;
    }

    /**
     * Search with simple filters
     * @param {any} filters
     */
    simpleSearch(filters) {
        let queryString = `?uploadedByMe=${filters.uploadedByMe}`;

        delete filters.uploadedByMe;

        for (let key in filters) {
            queryString += !!filters[key] ? `&${key}=${filters[key]}` : '';
        }
        return this.$http.get(this.URL + queryString).then(response => response.data);
    }

    /**
     * Search with complex filters
     * @param {any} filters
     */
    specificSearch(filters) {
        console.log(JSON.stringify(filters));

        // Transform filters that can be Or or Not
        [
            'author',
            'place',
        ].forEach(key => {
            filters[key] = {
                OR: filters[key].filter(item => item.op === 'OR').filter(item => !!item.value).map(item => item.value),
                NOT: filters[key].filter(item => item.op === 'NOT').filter(item => !!item.value).map(item => item.value)
            };
        });

        [
            'idCollective',
            'idComunarrProject',
            'idGeneralTopic',
            'idSpecificTopic',
            'idUser',
            'idContentType',
            'idFileType',
        ].forEach(key => {
            filters[key] = {
                OR: filters[key].filter(item => item.op === 'OR').filter(item => !!item.value).map(item => item.value),
                NOT: filters[key].filter(item => item.op === 'NOT').filter(item => !!item.value).map(item => item.value)
            };
        });

        filters.keyWords = {
            AND: filters.keyWords.filter(item => item.op === 'AND').filter(item => !!item.value).map(item => item.value),
            OR: filters.keyWords.filter(item => item.op === 'OR').filter(item => !!item.value).map(item => item.value),
            NOT: filters.keyWords.filter(item => item.op === 'NOT').filter(item => !!item.value).map(item => item.value)
        };
<commit_msg>fix Add id in catalogs instead of value<commit_after>/**
 * @name FilesService
 */

import angular from 'angular';
import FileSaver from 'file-saver';

export class FilesService {
    constructor($http, EnvironmentService) {
        'ngInject';

        this.$http = $http;
        this.URL = `${EnvironmentService.getCurrent().BASE_URL}/file`;
    }

    /**
     * Search with simple filters
     * @param {any} filters
     */
    simpleSearch(filters) {
        let queryString = `?uploadedByMe=${filters.uploadedByMe}`;

        delete filters.uploadedByMe;

        for (let key in filters) {
            queryString += !!filters[key] ? `&${key}=${filters[key]}` : '';
        }
        return this.$http.get(this.URL + queryString).then(response => response.data);
    }

    /**
     * Search with complex filters
     * @param {any} filters
     */
    specificSearch(filters) {
        console.log(JSON.stringify(filters));

        // Transform filters that can be Or or Not
        [
            'author',
            'place',
        ].forEach(key => {
            filters[key] = {
                OR: filters[key].filter(item => item.op === 'OR').filter(item => !!item.value).map(item => item.value),
                NOT: filters[key].filter(item => item.op === 'NOT').filter(item => !!item.value).map(item => item.value)
            };
        });

        [
            'idCollective',
            'idComunarrProject',
            'idGeneralTopic',
            'idSpecificTopic',
            'idUser',
            'idContentType',
            'idFileType',
        ].forEach(key => {
            filters[key] = {
                OR: filters[key].filter(item => item.op === 'OR').filter(item => !!item.id).map(item => item.value),
                NOT: filters[key].filter(item => item.op === 'NOT').filter(item => !!item.id).map(item => item.value)
            };
        });

        filters.keyWords = {
            AND: filters.keyWords.filter(item => item.op === 'AND').filter(item => !!item.value).map(item => item.value),
            OR: filters.keyWords.filter(item => item.op === 'OR').filter(item => !!item.value).map(item => item.value),
            NOT: filters.keyWords.filter(item => item.op === 'NOT').filter(item => !!item.value).map(item => item.value)
        };

{'fraction_non_alphanumeric': 0.17286652078774617, 'fraction_numerical': 0.0, 'mean_word_length': 2.0514018691588785, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 51, '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': '4030189', 'n_tokens_mistral': 1337, 'n_tokens_neox': 1306, 'n_words': 245}