<commit_before>$.fn.setupPie = function(total){
  var pieId = this.attr("id") + "pie";
  $(this).before("<div id='" +pieId+ "' class='multipie'></div>");
  var values = [];
  $("li span.number", this).each(function() {
    values.push( Math.round($(this).attr("data-cnt") * 100 / total))
  });
  $("#"+pieId).bindMultiPie(36.5, values);
  $(this).addMultiLegend();
}



/*
 Usage:
 $('table.metrics').occMetrics();

 Bind the divs to load on AJAX calls.
 For performance, we first determine which kingdoms have content, then load them all

 An optional table attribute data-address is used to define additional filters
 */
$.fn.occMetrics = function(){
  this.each(function() {
    var baseAddress = $(this).attr("data-address");
    //console.debug(baseAddress);
    $(this).find('td.total div').each(function() {
      _refresh(baseAddress, $(this), true);
    });
  });

  function _refresh(baseAddress, target, nest) {
    var $target = $(target);

    // always add the datasetKey to the cube address
    var query = "?" + baseAddress;

    if ($target.closest("tr").attr("data-kingdom") != null) {
      query += "&taxonKey=" + $target.closest("tr").attr("data-kingdom");
    }

    if ($target.hasClass("geo")) {
      query += "&isGeoreferenced=true";
    }
    var ws = cfg.wsMetrics + 'occurrence/count';

    if ($target.closest("td").attr("data-bor") === "OBSERVATION") {
      var observationTypes = ["OBSERVATION", "HUMAN_OBSERVATION", "MACHINE_OBSERVATION"];
      for (var i = 0; i < observationTypes; i++) {
        // Proxy query variable to avoid concatenating more basisOfRecord.
        var queryMod = query + "&basisOfRecord=" + observationTypes[i];
        $.getJSON(ws + queryMod + '&callback=?', function (data) {<commit_msg>adds missing .length to the for loop<commit_after>$.fn.setupPie = function(total){
  var pieId = this.attr("id") + "pie";
  $(this).before("<div id='" +pieId+ "' class='multipie'></div>");
  var values = [];
  $("li span.number", this).each(function() {
    values.push( Math.round($(this).attr("data-cnt") * 100 / total))
  });
  $("#"+pieId).bindMultiPie(36.5, values);
  $(this).addMultiLegend();
}



/*
 Usage:
 $('table.metrics').occMetrics();

 Bind the divs to load on AJAX calls.
 For performance, we first determine which kingdoms have content, then load them all

 An optional table attribute data-address is used to define additional filters
 */
$.fn.occMetrics = function(){
  this.each(function() {
    var baseAddress = $(this).attr("data-address");
    //console.debug(baseAddress);
    $(this).find('td.total div').each(function() {
      _refresh(baseAddress, $(this), true);
    });
  });

  function _refresh(baseAddress, target, nest) {
    var $target = $(target);

    // always add the datasetKey to the cube address
    var query = "?" + baseAddress;

    if ($target.closest("tr").attr("data-kingdom") != null) {
      query += "&taxonKey=" + $target.closest("tr").attr("data-kingdom");
    }

    if ($target.hasClass("geo")) {
      query += "&isGeoreferenced=true";
    }
    var ws = cfg.wsMetrics + 'occurrence/count';

    if ($target.closest("td").attr("data-bor") === "OBSERVATION") {
      var observationTypes = ["OBSERVATION", "HUMAN_OBSERVATION", "MACHINE_OBSERVATION"];
      for (var i = 0; i < observationTypes.length; i++) {
        // Proxy query variable to avoid concatenating more basisOfRecord.
        var queryMod = query + "&basisOfRecord=" + observationTypes[i];
        $.getJSON(ws + queryMod + '&callback=?', function (data) {
{'fraction_non_alphanumeric': 0.18526912181303115, 'fraction_numerical': 0.00396600566572238, 'mean_word_length': 3.6399474375821286, 'pattern_counts': {'":': 0, '<': 9, '<?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': '2860107', 'n_tokens_mistral': 1161, 'n_tokens_neox': 1118, 'n_words': 272}