<commit_before>var swig 		     	= require('swig');
var mongoose 		  = require ('mongoose');
var friendModel 	= require('../models/friend-model')();
var userModel     =require('../models/user-model')();

var sampleUser = new userModel({
  email:      '<EMAIL>',
  name:       'adri',
  password:   '<PASSWORD>',
});

// TODO: Genera la pagina del muro (Si usuario logueado)
exports.index = function(req, res) {
  var baseweb = swig.compileFile('views/base.html');
  var pieceFriend = swig.compileFile('views/piece-friend.html');

  var listRes;
  friendModel.list(sampleUser,function (err, friends) {
    listRes = Array();
    friends.forEach(function(friend) {
      listRes.push(pieceFriend(friend));
    });
  });

  res.status(200);
  res.send(baseweb({'content' : listRes}));
  res.end();
};

// TODO: Añade una peticion de amistad
exports.add = function(req, res) {
  var amigo = new friendModel ({
    user:       req.session.user,
    friend:     sampleUser,
    acepted:    false
  });
  amigo.save();
};

// TODO: Acepta una peticion de amistad
exports.accept = function(req, res) {
  friendModel.find({
    user:       req.session.user,
    friend:     sampleUser,
    acepted:    false<commit_msg>Added list of users<commit_after>var swig 		     	= require('swig');
var mongoose 		  = require ('mongoose');
var friendModel 	= require('../models/friend-model')();
var userModel     = require('../models/user-model')();

var sampleUser = new userModel({
  email:      '<EMAIL>',
  name:       'adri',
  password:   '<PASSWORD>',
});

// TODO: Genera la pagina del muro (Si usuario logueado)
exports.index = function(req, res) {
  var baseweb = swig.compileFile('views/base.html');
  var pieceFriend = swig.compileFile('views/piece-friend.html');

  var listRes;
  friendModel.list(sampleUser,function (err, friends) {
    console.log("amigos: " + friends);
    listRes = Array();
    friends.forEach(function(friend) {
      listRes.push(pieceFriend(friend));
    });
  });

  console.log("listado: " + listRes);

  res.status(200);
  res.send(baseweb({'content' : listRes}));
  res.end();
};

exports.users = function(req, res) {
  var baseweb = swig.compileFile('views/base.html');
  var pieceFriend = swig.compileFile('views/piece-friend.html');

  var x = mongoose.model('User');
  var usuariosRenders = Array();
  userModel.find({}, function(err, usuarios) {
      if (!err){
        usuarios.forEach(function(usuario) {
          usuariosRenders.push(pieceFriend(usuario));
        });
      }
      else { throw err;}
      }
    );
  res.status(200);
  res.send(baseweb({'content' : usuariosRenders}));
  console.log(usuariosRenders);
  res.end();
};

// TODO: Añade una peticion de amistad
exports.add = function(req, res) {
  var amigo = new friendModel ({
    user:       req.session.user,
    friend:     sampleUser,
    acepted:    false
  });
  amigo.save();
};

// TODO: Acepta una peticion de amistad
exports.accept = function(req, res) {
  friendModel.find({
    user:       req.session.user,
    friend:     sampleUser,
    acepted:    false
{'fraction_non_alphanumeric': 0.15998696643857935, 'fraction_numerical': 0.002932551319648094, 'mean_word_length': 3.188267394270123, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '499716', 'n_tokens_mistral': 1051, 'n_tokens_neox': 1057, 'n_words': 216}