<commit_before>const util = require('util');
const memjs = require('memjs');
const Tuc = require('tuc');
const S = require('string');
const tuc = new Tuc();
const mc = memjs.Client.create();
const expire = 60; // 1 min

module.exports.balance = (req, res) => {

  let account = req.params.account;
  let stringKey = util.format('tuc_%d', account);

  mc.get(stringKey, (err, value, key) => {
    if (value === null) {
      // get account balance
      tuc.getBalance(account, (balance) => {
        if (tuc.isError(balance)) {
          res.json(balance);
        } else {
          // get account type
          tuc.getType(account, (type) => {
            let response = {
              account: account,
              balance: balance,
              type: type,
            };

            // save result ond memcached
            mc.set(stringKey, JSON.stringify(response), (err, success) => {
              response.source = 'request';
              res.json(response);
            }, expire);
          });
        }
      });
    } else {
      let memcachedResponse = JSON.parse(value);
      memcachedResponse.source = 'memcached';
      res.json(memcachedResponse);
    }
  });
};
<commit_msg>Remove type<commit_after>const util = require('util');
const memjs = require('memjs');
const Tuc = require('tuc');
const S = require('string');
const tuc = new Tuc();
const mc = memjs.Client.create();
const expire = 60; // 1 min

module.exports.balance = (req, res) => {

  let account = req.params.account;
  let stringKey = util.format('tuc_%d', account);

  mc.get(stringKey, (err, value, key) => {
    if (value === null) {
      // get account balance
      tuc.getBalance(account, (balance) => {
        if (tuc.isError(balance)) {
          res.json(balance);
        } else {
          let response = {
            account: account,
            balance: balance,
          };

          // save result ond memcached
          mc.set(stringKey, JSON.stringify(response), (err, success) => {
            response.source = 'request';
            res.json(response);
          }, expire);
        }
      });
    } else {
      let memcachedResponse = JSON.parse(value);
      memcachedResponse.source = 'memcached';
      res.json(memcachedResponse);
    }
  });
};

{'fraction_non_alphanumeric': 0.1498901098901099, 'fraction_numerical': 0.0026373626373626374, 'mean_word_length': 2.075675675675676, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 12, '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': '2074609', 'n_tokens_mistral': 691, 'n_tokens_neox': 669, 'n_words': 158}