<commit_before>
var users = require('../../stores/users');
var template = require('./template.ejs');
var listTemplate = require('./list.ejs');
var emitter = require('component-emitter');

module.exports = function () {

  // Init
  emitter(this);

  // Public methods

  this.bind = function ($mount) {

    $mount.html(template());

    // Fetch users and include to page.
    users.getAll(function (err, rawUsers) {
      // Hide loading bar
      $('#tresdb-users-loading').addClass('hidden');

      if (err) {
        console.error(err);
        return;
      }

      // Backward compatibility 8.3.3 -> 8.3.4
      rawUsers = rawUsers.map(function (u) {
        return Object.assign({}, u, {
          points7days: u.points7days ? u.points7days : 0,
          points30days: u.points30days ? u.points30days : 0,
        });
      });

      var activeUsers = rawUsers.filter(function (u) {
        return u.status === 'active';
      });
      var passiveUsers = rawUsers.filter(function (u) {
        return u.status === 'deactivated';
      });

      // Order by points
      var bestUsersAllTime = activeUsers.sort(function (ua, ub) {
        return ub.points - ua.points;
      });
      var bestUsersOf30days = activeUsers.sort(function (ua, ub) {
        return ub.points30days - ua.points30days;
      }).slice(0, 5);
      var bestUsersOf7days = activeUsers.sort(function (ua, ub) {
        return ub.points7days - ua.points7days;
      }).slice(0, 5);

      // Reveal list
      $('#tresdb-users-alltime').html(listTemplate({
        users: bestUsersAllTime,
      }));

      $('#tresdb-users-30days').html(listTemplate({
        users: bestUsersOf30days.map(function (u) {
          // Template uses u.points
          return Object.assign({}, u, { points: u.points30days });
        }),
        prefix: '+',
      }));

      $('#tresdb-users-7days').html(listTemplate({
        users: bestUsersOf7days.map(function (u) {
          // Template uses u.points
          return Object.assign({}, u, { points: u.points7days });<commit_msg>Correct order of all time top<commit_after>
var users = require('../../stores/users');
var template = require('./template.ejs');
var listTemplate = require('./list.ejs');
var emitter = require('component-emitter');

module.exports = function () {

  // Init
  emitter(this);

  // Public methods

  this.bind = function ($mount) {

    $mount.html(template());

    // Fetch users and include to page.
    users.getAll(function (err, rawUsers) {
      // Hide loading bar
      $('#tresdb-users-loading').addClass('hidden');

      if (err) {
        console.error(err);
        return;
      }

      // Backward compatibility 8.3.3 -> 8.3.4
      rawUsers = rawUsers.map(function (u) {
        return Object.assign({}, u, {
          points7days: u.points7days ? u.points7days : 0,
          points30days: u.points30days ? u.points30days : 0,
        });
      });

      var activeUsers = rawUsers.filter(function (u) {
        return u.status === 'active';
      });
      var passiveUsers = rawUsers.filter(function (u) {
        return u.status === 'deactivated';
      });

      // Order by points
      var bestUsersAllTime = activeUsers.sort(function (ua, ub) {
        return ub.points - ua.points;
      });
      var VIEW_TOP = 5;
      // Slice to copy because sort manipulates the original.
      var bestUsersOf30days = activeUsers.slice().sort(function (ua, ub) {
        return ub.points30days - ua.points30days;
      }).slice(0, VIEW_TOP);
      var bestUsersOf7days = activeUsers.slice().sort(function (ua, ub) {
        return ub.points7days - ua.points7days;
      }).slice(0, VIEW_TOP);

      // Reveal list
      $('#tresdb-users-alltime').html(listTemplate({
        users: bestUsersAllTime,
      }));

      $('#tresdb-users-30days').html(listTemplate({
        users: bestUsersOf30days.map(function (u) {
          // Template uses u.points
          return Object.assign({}, u, { points: u.points30days });
        }),
        prefix: '+',
      }));

      $('#tresdb-users-7days').html(listTemplate({
        users: bestUsersOf7days.map(function (u) {
          // Template uses u.points
          return Object.assign({}, u, { points: u.points7days });
{'fraction_non_alphanumeric': 0.15400943396226416, 'fraction_numerical': 0.018160377358490565, 'mean_word_length': 2.2875968992248064, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '2629759', 'n_tokens_mistral': 1332, 'n_tokens_neox': 1283, 'n_words': 282}