<commit_before>'use strict';

var config = require('meanio').loadConfig(),
  actionSettings = require(process.cwd() + '/config/actionSettings') || {};

var request = require('request');

var redis = require('redis'),
  client = redis.createClient();

client.on('error', function(err) {
  console.log('Error ' + err);
});


var getCircles = exports.getCircles = function(type, user, callback) {
  var api = '/api/v1/circles/' + type + '?user=' + user;
  client.get(api, function(err, reply) {
    if (reply) return callback(null, reply);
    request(config.circles.uri + api, function(error, response, body) {
      if (error || response.statusCode !== 200) return callback(error || response.statusCode);
      client.setex(api, actionSettings.cacheTime, body, redis.print);
      return callback(null, body);
    });
  });
};

exports.all = function(req, res, next) {
  getCircles('all', req.user.id, function(err, data) {
    return res.send(data);
  })
};

exports.sources = function(req, res, next) {
  getCircles('sources', req.user.id, function(err, data) {
    return res.send(data);
  })
};

exports.mine = function(req, res, next) {<commit_msg>request querystring<commit_after>'use strict';

var config = require('meanio').loadConfig(),
  actionSettings = require(process.cwd() + '/config/actionSettings') || {};

var request = require('request'),
  qs = require('querystring');

var redis = require('redis'),
  client = redis.createClient();

client.on('error', function(err) {
  console.log('Error ' + err);
});


var getCircles = exports.getCircles = function(type, user, callback) {
  var query = qs.stringify({user: user})
  var api = '/api/v1/circles/' + type + '?' + query;
  client.get(api, function(err, reply) {
    if (reply) return callback(null, reply);
    request(config.circles.uri + api, function(error, response, body) {
      if (error || response.statusCode !== 200) return callback(error || response.statusCode);
      client.setex(api, actionSettings.cacheTime, body, redis.print);
      return callback(null, body);
    });
  });
};

exports.all = function(req, res, next) {
  getCircles('all', req.user.id, function(err, data) {
    return res.send(data);
  })
};

exports.sources = function(req, res, next) {
  getCircles('sources', req.user.id, function(err, data) {
    return res.send(data);
  })
};

exports.mine = function(req, res, next) {
{'fraction_non_alphanumeric': 0.17830109335576114, 'fraction_numerical': 0.00336417157275021, 'mean_word_length': 4.274944567627495, 'pattern_counts': {'":': 0, '<': 3, '<?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': '4146596', 'n_tokens_mistral': 783, 'n_tokens_neox': 771, 'n_words': 172}