<commit_before>var google = require('server/helpers/google');

module.exports = function render(content, user) {
  if(content instanceof Array) {
    return content.map(function(model) { return renderObject(model, user); });
  }

  return renderObject(content, user);
};

function renderObject(model, user) {
  var result = {};
  var isAllowed = user && (user.role === 'admin' || model.id === user.id);

  result.id = model.id;
  result.name = model.name;
  result.img = model.img || model.facebook && model.facebook.id && ('//graph.facebook.com/'+model.facebook.id+'/picture?width=400&height=400') || model.google && model.google.id && model.google.img || model.fenix && model.fenix.id && ('https://fenix.tecnico.ulisboa.pt/user/photo/' + model.fenix.id);
  result.role = model.role,
  result.points = model.points && {
    available: model.points && model.points.available,
    total: model.points && model.points.total
  };
  result.achievements = model.achievements && model.achievements.map(function(achievement) {
    return {
      id: achievement && achievement.id,
      date: achievement && achievement.date
    };
  });
  result.area = model.area;
  result.skills = model.skills;
  result.registered = model.registered;

  if(isAllowed){
    result.mail = model.mail;
    result.facebook = model.facebook && {
      id: model.facebook && model.facebook.id<commit_msg>Return 0 if the user has no points<commit_after>var google = require('server/helpers/google');

module.exports = function render(content, user) {
  if(content instanceof Array) {
    return content.map(function(model) { return renderObject(model, user); });
  }

  return renderObject(content, user);
};

function renderObject(model, user) {
  var result = {};
  var isAllowed = user && (user.role === 'admin' || model.id === user.id);

  result.id = model.id;
  result.name = model.name;
  result.img = model.img || model.facebook && model.facebook.id && ('//graph.facebook.com/'+model.facebook.id+'/picture?width=400&height=400') || model.google && model.google.id && model.google.img || model.fenix && model.fenix.id && ('https://fenix.tecnico.ulisboa.pt/user/photo/' + model.fenix.id);
  result.role = model.role,
  result.points = model.points && {
    available: model.points && model.points.available || 0,
    total: model.points && model.points.total || 0
  };
  result.achievements = model.achievements && model.achievements.map(function(achievement) {
    return {
      id: achievement && achievement.id,
      date: achievement && achievement.date
    };
  });
  result.area = model.area;
  result.skills = model.skills;
  result.registered = model.registered;

  if(isAllowed){
    result.mail = model.mail;
    result.facebook = model.facebook && {
      id: model.facebook && model.facebook.id
{'fraction_non_alphanumeric': 0.16289917473986365, 'fraction_numerical': 0.005382131324004306, 'mean_word_length': 3.757679180887372, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, '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': '1417570', 'n_tokens_mistral': 885, 'n_tokens_neox': 869, 'n_words': 168}