<commit_before>define(['sorttable', 'snabbdom', 'helper'], function (SortTable, V, helper) {
  'use strict';
  V = V.default;

  function showUptime(uptime) {
    // 1000ms are 1 second and 60 second are 1min: 60 * 1000 =  60000
    var s = uptime / 60000;
    if (Math.abs(s) < 60) {
      return Math.round(s) + ' m';
    }
    s /= 60;
    if (Math.abs(s) < 24) {
      return Math.round(s) + ' h';
    }
    s /= 24;
    return Math.round(s) + ' d';
  }

  var headings = [{
    name: ''
  }, {
    name: 'node.nodes',
    sort: function (a, b) {
      return a.hostname.localeCompare(b.hostname);
    },
    reverse: false
  }, {
    name: 'node.uptime',
    class: 'ion-time',
    sort: function (a, b) {
      return a.uptime - b.uptime;
    },
    reverse: true
  }, {
    name: 'node.links',
    class: 'ion-share-alt',
    sort: function (a, b) {
      return a.neighbours.length - b.neighbours.length;
    },
    reverse: true
  }, {
    name: 'node.clients',
    class: 'ion-people',
    sort: function (a, b) {
      return a.clients - b.clients;
    },
    reverse: true
  }, {
    name: 'node.systemLoad',
    class: 'ion-connection-bars',
    sort: function (a, b) {
      return a.loadavg - b.loadavg;
    },
    reverse: true
  }];

  return function () {
    function renderRow(d) {
      var td0Content = '';
      if (helper.hasLocation(d)) {
        td0Content = V.h('span', { props: { className: 'icon ion-location', title: _.t('location.location') } });
      }

      var td1Content = V.h('a', {
        props: {
          className: ['hostname', d.is_online ? 'online' : 'offline'].join(' '),
          href: router.generateLink({ node: d.node_id })
        }, on: {
          click: function (e) {
            router.fullUrl({ node: d.node_id }, e);
          }
        }
      }, d.hostname);

      return V.h('tr', [
        V.h('td', td0Content),
        V.h('td', td1Content),
        V.h('td', showUptime(d.uptime)),
        V.h('td', d.neighbours.length),
        V.h('td', d.clients),
        V.h('td', d.loadavg.toFixed(2))
      ]);
    }

    var table = new SortTable(headings, 1, renderRow);

    this.render = function render(d) {
      var h2 = document.createElement('h2');
      h2.textContent = _.t('node.all');
      d.appendChild(h2);
      table.el.elm.classList.add('node-list');
      d.appendChild(table.el.elm);
    };

    this.setData = function setData(d) {
      var data = d.nodes.all.map(function (e) {<commit_msg>Revert "Update nodelist.js: Sortable loadavg"<commit_after>define(['sorttable', 'snabbdom', 'helper'], function (SortTable, V, helper) {
  'use strict';
  V = V.default;

  function showUptime(uptime) {
    // 1000ms are 1 second and 60 second are 1min: 60 * 1000 =  60000
    var s = uptime / 60000;
    if (Math.abs(s) < 60) {
      return Math.round(s) + ' m';
    }
    s /= 60;
    if (Math.abs(s) < 24) {
      return Math.round(s) + ' h';
    }
    s /= 24;
    return Math.round(s) + ' d';
  }

  var headings = [{
    name: ''
  }, {
    name: 'node.nodes',
    sort: function (a, b) {
      return a.hostname.localeCompare(b.hostname);
    },
    reverse: false
  }, {
    name: 'node.uptime',
    class: 'ion-time',
    sort: function (a, b) {
      return a.uptime - b.uptime;
    },
    reverse: true
  }, {
    name: 'node.links',
    class: 'ion-share-alt',
    sort: function (a, b) {
      return a.neighbours.length - b.neighbours.length;
    },
    reverse: true
  }, {
    name: 'node.clients',
    class: 'ion-people',
    sort: function (a, b) {
      return a.clients - b.clients;
    },
    reverse: true
  }];

  return function () {
    function renderRow(d) {
      var td0Content = '';
      if (helper.hasLocation(d)) {
        td0Content = V.h('span', { props: { className: 'icon ion-location', title: _.t('location.location') } });
      }

      var td1Content = V.h('a', {
        props: {
          className: ['hostname', d.is_online ? 'online' : 'offline'].join(' '),
          href: router.generateLink({ node: d.node_id })
        }, on: {
          click: function (e) {
            router.fullUrl({ node: d.node_id }, e);
          }
        }
      }, d.hostname);

      return V.h('tr', [
        V.h('td', td0Content),
        V.h('td', td1Content),
        V.h('td', showUptime(d.uptime)),
        V.h('td', d.neighbours.length),
        V.h('td', d.clients)
      ]);
    }

    var table = new SortTable(headings, 1, renderRow);

    this.render = function render(d) {
      var h2 = document.createElement('h2');
      h2.textContent = _.t('node.all');
      d.appendChild(h2);
      table.el.elm.classList.add('node-list');
      d.appendChild(table.el.elm);
    };

    this.setData = function setData(d) {
      var data = d.nodes.all.map(function (e) {
{'fraction_non_alphanumeric': 0.1777638190954774, 'fraction_numerical': 0.017797319932998323, 'mean_word_length': 2.07598197037991, 'pattern_counts': {'":': 0, '<': 7, '<?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': '7508519', 'n_tokens_mistral': 1793, 'n_tokens_neox': 1717, 'n_words': 367}