<commit_before>/**
* Here are methods, they are ways to encapsule some specific functions, usually
* functions that work with collections (database).
*/

Meteor.methods({
  followUser : function(friendId){
    Friendships.follow(friendId);//collection
  },
  unfollowUser : function(friendId){
    Friendships.unfollow(friendId);
  },
  profileUpdate : function(name, about){
    Meteor.users.update({
        //_id: Meteor.user()._id
        _id: this.userId
    }, {
        $set: {
            "profile.firstName": name,
            "profile.about": about
        }
    });
  },
  publishPost : function(message, name){
    Posts.publish(message, name);
  },
  publishPostWithColor : function(message, name, color){
    Posts.publishWithColor(message, name, color);
  },
  commentOnPost : function(comment, postId){
    Posts.commentOnPost(comment, postId);
  }
  ,
  addAchievement : function(achievement, userId){
    Achievements.addAchievement(achievement, userId);
  },
  increasePontuation : function (pointsToIncrease, type, userId){
    Points.increasePontuation(pointsToIncrease, type, userId);
  },
});<commit_msg>now the total amount of points from an user is saved directly in his document on database<commit_after>/**
* Here are methods, they are ways to encapsule some specific functions, usually
* functions that work with collections (database).
*/

Meteor.methods({
  followUser : function(friendId){
    Friendships.follow(friendId);//collection
  },
  unfollowUser : function(friendId){
    Friendships.unfollow(friendId);
  },
  profileUpdate : function(name, about){
    Meteor.users.update({
        //_id: Meteor.user()._id
        _id: this.userId
    }, {
        $set: {
            "profile.firstName": name,
            "profile.about": about
        }
    });
  },
  publishPost : function(message, name){
    Posts.publish(message, name);
  },
  publishPostWithColor : function(message, name, color){
    Posts.publishWithColor(message, name, color);
  },
  commentOnPost : function(comment, postId){
    Posts.commentOnPost(comment, postId);
  }
  ,
  addAchievement : function(achievement, userId){
    Achievements.addAchievement(achievement, userId);
  },
  increasePontuation : function (pointsToIncrease, type, userId){
    Points.increasePontuation(pointsToIncrease, type, userId);
    //it will also add the total amount of points directly to the user documents
    var points =  Points.listPointsFromUser(userId);
    var totalPoints = 0;
    points.map(function(x){totalPoints += x.points;});
    console.log('will insert ' + totalPoints + ' to the user ' + userId);
    Meteor.users.update(userId, {$set: {"totalPoints": totalPoints}});
  },
});
{'fraction_non_alphanumeric': 0.1260691706954258, 'fraction_numerical': 0.0003718854592785422, 'mean_word_length': 3.590443686006826, 'pattern_counts': {'":': 5, '<': 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': '7629622', 'n_tokens_mistral': 818, 'n_tokens_neox': 810, 'n_words': 187}