<commit_before>import { csv } from "d3-fetch";
import { mean, median, sum } from "d3-array";
import axios from "axios";

const endPointGobiertoData = `/api/v1/data/data.json`

export function getRemoteData(endpoint) {
  return csv(endpoint, { headers: { Authorization: "Bearer FmC7jKbXJbzLn1UnmWMXbNXe" } });
}

export function sortByField(dateField) {
  return function(a, b) {
    const aDate = a[dateField],
      bDate = b[dateField];

    if (aDate == "") {
      return 1;
    }

    if (bDate == "") {
      return -1;
    }

    if (aDate < bDate) {
      return 1;
    } else if (aDate > bDate) {
      return -1;
    } else {
      return 0;
    }
  };
}

export function sumDataByGroupKey(data, group, value) {
  let counts = data.reduce((prev, curr) => {
    let count = prev.get(curr[group]) || 0;
    prev.set(curr[group], curr[value] + count);<commit_msg>Update utils.js<commit_after>import { csv } from "d3-fetch";
import { mean, median, sum } from "d3-array";
import axios from "axios";

const endPointGobiertoData = `/api/v1/data/data.json`

export function getRemoteData(endpoint) {
  return csv(endpoint);
}

export function sortByField(dateField) {
  return function(a, b) {
    const aDate = a[dateField],
      bDate = b[dateField];

    if (aDate == "") {
      return 1;
    }

    if (bDate == "") {
      return -1;
    }

    if (aDate < bDate) {
      return 1;
    } else if (aDate > bDate) {
      return -1;
    } else {
      return 0;
    }
  };
}

export function sumDataByGroupKey(data, group, value) {
  let counts = data.reduce((prev, curr) => {
    let count = prev.get(curr[group]) || 0;
    prev.set(curr[group], curr[value] + count);
{'fraction_non_alphanumeric': 0.15044776119402986, 'fraction_numerical': 0.011940298507462687, 'mean_word_length': 2.8352402745995424, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, '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': '3519605', 'n_tokens_mistral': 624, 'n_tokens_neox': 608, 'n_words': 146}