<commit_before>const $ = require("jquery");
const Configuration = require("./Configuration");
const _ = require("lodash");

/**
 * Created by bladron on 08/04/16.
 * Utility which allows to not duplicate the code configuration for JQuery ajax call.
 * It is intended to use only JSon for both sent and received data.
 */

class CallAjax {
    static callCount = 0;

    constructor(ajaxQuery) {
        this.ajaxQuery = ajaxQuery;
        CallAjax.callCount++;
        Configuration.showSpinner();
    }

    static _configure = (type, url, data, additionalConfig = {}) => {
        let configuration = {
            type: type,
            url: url.toString()
        };

        if(additionalConfig.processData === false) {
            configuration.data = data;
        } else if(data) {
            configuration.data = JSON.stringify(data);
            configuration.contentType = 'text/json';
        }
        if(Configuration.getAuthToken) {
            configuration.headers = {"X-AUTH-TOKEN": Configuration.getAuthToken()};
            configuration.xhrFields = {withCredentials: true};
        }
        configuration = _.merge(configuration, additionalConfig);

        return new CallAjax($.ajax(configuration));
    };

    static get = (url) => CallAjax._configure("GET", url);
    static post = (url, data) => CallAjax._configure("POST", url, data);
    static put = (url, data) => CallAjax._configure("PUT", url, data);
    static delete = (url, data) => CallAjax._configure("DELETE", url, data);
    static uploadFile = (url, data) => CallAjax._configure("POST", url, data, { processData: false });
    static callAjax = (url, data) => new CallAjax($.ajax({
        type: "POST",
        url: url,
        data: data,
        processData: false,
        contentType: false
    }));

    /**
     * Call several CallAjax in parallel.
     * This method is similar to Promise.all()
     * @param callAjaxList {Array.<CallAjax>}
     * @returns {CallAjax}
     */
    static all = (...callAjaxList) => {
        // Extract ajaxQuery from arguments (array of CallAjax)
        let ajaxQueries = _.map(callAjaxList, (c) => c.ajaxQuery);
        let callThemAll = new CallAjax($.when(...ajaxQueries));
        // Several CallAjax were performed but we're getting only one callback, so we need to force hide spinner
        callThemAll.always(CallAjax._resetCount);
<commit_msg>Remove useless method in CallAjax<commit_after>const $ = require("jquery");
const Configuration = require("./Configuration");
const _ = require("lodash");

/**
 * Created by bladron on 08/04/16.
 * Utility which allows to not duplicate the code configuration for JQuery ajax call.
 * It is intended to use only JSon for both sent and received data.
 */

class CallAjax {
    static callCount = 0;

    constructor(ajaxQuery) {
        this.ajaxQuery = ajaxQuery;
        CallAjax.callCount++;
        Configuration.showSpinner();
    }

    static _configure = (type, url, data, additionalConfig = {}) => {
        let configuration = {
            type: type,
            url: url.toString()
        };

        if(additionalConfig.processData === false) {
            configuration.data = data;
        } else if(data) {
            configuration.data = JSON.stringify(data);
            configuration.contentType = 'text/json';
        }
        if(Configuration.getAuthToken) {
            configuration.headers = {"X-AUTH-TOKEN": Configuration.getAuthToken()};
            configuration.xhrFields = {withCredentials: true};
        }
        configuration = _.merge(configuration, additionalConfig);

        return new CallAjax($.ajax(configuration));
    };

    static get = (url) => CallAjax._configure("GET", url);
    static post = (url, data) => CallAjax._configure("POST", url, data);
    static put = (url, data) => CallAjax._configure("PUT", url, data);
    static delete = (url, data) => CallAjax._configure("DELETE", url, data);
    static uploadFile = (url, data) => CallAjax._configure("POST", url, data, { processData: false });

    /**
     * Call several CallAjax in parallel.
     * This method is similar to Promise.all()
     * @param callAjaxList {Array.<CallAjax>}
     * @returns {CallAjax}
     */
    static all = (...callAjaxList) => {
        // Extract ajaxQuery from arguments (array of CallAjax)
        let ajaxQueries = _.map(callAjaxList, (c) => c.ajaxQuery);
        let callThemAll = new CallAjax($.when(...ajaxQueries));
        // Several CallAjax were performed but we're getting only one callback, so we need to force hide spinner
        callThemAll.always(CallAjax._resetCount);

{'fraction_non_alphanumeric': 0.12741061755146263, 'fraction_numerical': 0.0030335861321776816, 'mean_word_length': 2.6780876494023906, 'pattern_counts': {'":': 2, '<': 5, '<?xml version=': 0, '>': 22, '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': '1192658', 'n_tokens_mistral': 1311, 'n_tokens_neox': 1277, 'n_words': 362}