<commit_before>module.exports.name = 'activity';
const Util = require('../classes/Util.js');

module.exports.alias = [
  'activity'
];

module.exports.isAllowed = () => {
  return true;
};

module.exports.help = '`,activity [ user ] [ -m ]` Displays server or user activity for the past 30 days (UTC). Use `-m` to show numbers';

const MONTH = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sept', 'Oct', 'Nov', 'Dec'];
const DAY = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];

function dateToString(d) {
  const month = MONTH[d.getUTCMonth()];
  const date = d.getUTCDate();
  const day = DAY[d.getUTCDay()];
  return `${month} ${date < 10 ? `0${date}` : date}(${day})`;
}

module.exports.command = async (message, content, bot, server) => {
  const thirtyDays = new Array(30).fill(0);
  let bar = true;
  if (content.includes('-n')) {
    content = content.replace('-n', '');
    bar = false;
  }
  let u =  await Util.searchUser(message, content, server, bot);
  if (u) {
    let record = server.users[u.id];
    let count = 0;
    for (let i = server.today; i > server.today - 30; i--) {
      let chans = record.record[(i + 31) % 31]; // for under flows
      for (let ch in chans) {
        if (ch == 'jpn' || ch == 'eng' || ch == 'vc' || ch == 'rxn') continue;
        thirtyDays[count] += chans[ch];
      }
      count++;
    }
  } else {
    for (let id in server.users) {
      let record = server.users[id];
      let count = 0;
      for (let i = server.today; i > server.today - 30; i--) {
        let chans = record.record[(i + 31) % 31]; // for under flows
        for (let ch in chans) {
          if (ch == 'jpn' || ch == 'eng' || ch == 'vc' || ch == 'rxn') continue;
          thirtyDays[count] += chans[ch];
        }
        count++;
      }
    }
  }
  let date = new Date();
  let s = '```';
  if (bar) {
    const max = Math.max(...thirtyDays);
    const maxBar = '････････････････････';
    for (let c of thirtyDays) {
      s = `${s}\n${dateToString(date)}: ${maxBar.substr(0, 20 * c / max)}`;
      date.setDate(date.getUTCDate() - 1);
    }
  } else {
    for (let c of thirtyDays) {
      s = `${s}\n${dateToString(date)}: ${c}`;
      date.setDate(date.getUTCDate() - 1);
    }
  }
  
  message.channel.send(s + '```', {split: true});<commit_msg>flip order<commit_after>module.exports.name = 'activity';
const Util = require('../classes/Util.js');

module.exports.alias = [
  'activity'
];

module.exports.isAllowed = () => {
  return true;
};

module.exports.help = '`,activity [ user ] [ -m ]` Displays server or user activity for the past 30 days (UTC). Use `-m` to show numbers';

const MONTH = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sept', 'Oct', 'Nov', 'Dec'];
const DAY = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];

function dateToString(d) {
  const month = MONTH[d.getUTCMonth()];
  const date = d.getUTCDate();
  const day = DAY[d.getUTCDay()];
  return `${month} ${date < 10 ? `0${date}` : date}(${day})`;
}

module.exports.command = async (message, content, bot, server) => {
  const thirtyDays = new Array(30).fill(0);
  let bar = true;
  if (content.includes('-n')) {
    content = content.replace('-n', '');
    bar = false;
  }
  let u =  await Util.searchUser(message, content, server, bot);
  if (u) {
    let record = server.users[u.id];
    let count = 0;
    for (let i = server.today; i > server.today - 30; i--) {
      let chans = record.record[(i + 31) % 31]; // for under flows
      for (let ch in chans) {
        if (ch == 'jpn' || ch == 'eng' || ch == 'vc' || ch == 'rxn') continue;
        thirtyDays[count] += chans[ch];
      }
      count++;
    }
  } else {
    for (let id in server.users) {
      let record = server.users[id];
      let count = 0;
      for (let i = server.today; i > server.today - 30; i--) {
        let chans = record.record[(i + 31) % 31]; // for under flows
        for (let ch in chans) {
          if (ch == 'jpn' || ch == 'eng' || ch == 'vc' || ch == 'rxn') continue;
          thirtyDays[count] += chans[ch];
        }
        count++;
      }
    }
  }
  let date = new Date();
  let s = '```';
  if (bar) {
    const max = Math.max(...thirtyDays);
    const maxBar = '････････････････････';
    for (let c of thirtyDays) {
      s = `${dateToString(date)}: ${maxBar.substr(0, 20 * c / max)}\n${s}`;
      date.setDate(date.getUTCDate() - 1);
    }
  } else {
    for (let c of thirtyDays) {
      s = `${s}\n${dateToString(date)}: ${c}\n\n${s}`;
      date.setDate(date.getUTCDate() - 1);
    }
  }
  
  message.channel.send(s + '```', {split: true});
{'fraction_non_alphanumeric': 0.2180352864299717, 'fraction_numerical': 0.011762143323894577, 'mean_word_length': 2.5875, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 11, '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': '469977', 'n_tokens_mistral': 1852, 'n_tokens_neox': 1745, 'n_words': 450}