<commit_before>var models = require('../../models'),
    Promise = require('es6-promise').Promise,
    _ = require('lodash');

// Passport session setup.
//   To support persistent login sessions, Passport needs to be able to
//   serialize users into and deserialize users out of the session.  Typically,
//   this will be as simple as storing the user ID when serializing, and finding
//   the user by ID when deserializing.  However, since this example does not
//   have a database of user records, the complete Facebook profile is serialized
//   and deserialized.
module.exports = function(passport) {
    passport.serializeUser(function(user, done) {
        var id = user.user.id;
        done(null, id);
    });

    passport.deserializeUser(function(facebookId, done) {
        getUser(facebookId).then(function(user, results) {
            done(null, user);
        }).catch(done);
    });
};

function getUser(id) {
    return new Promise(function(resolve, reject) {
        models.users.find({
            where: {
                facebook_id: id
            }
        }).success(function(user) {
            resolve(user.dataValues);
        }).error(reject);
    });
}
//
// function getResults(userId) {
//     return new Promise(function(resolve, reject) {
//         models.quiz_results.findAll({
//             where: {
//                 user_id: userId
//             }
//         }).success(function(results) {
//             resolve(_.pluck(results, 'dataValues'));
//         }).error(reject);
//     });
// }
<commit_msg>remove results from current user<commit_after>var models = require('../../models'),
    Promise = require('es6-promise').Promise,
    _ = require('lodash');

// Passport session setup.
//   To support persistent login sessions, Passport needs to be able to
//   serialize users into and deserialize users out of the session.  Typically,
//   this will be as simple as storing the user ID when serializing, and finding
//   the user by ID when deserializing.  However, since this example does not
//   have a database of user records, the complete Facebook profile is serialized
//   and deserialized.
module.exports = function(passport) {
    passport.serializeUser(function(user, done) {
        var id = user.user.id;
        done(null, id);
    });

    passport.deserializeUser(function(facebookId, done) {
        getUser(facebookId).then(function(user, results) {
            done(null, user);
        }).catch(done);
    });
};

function getUser(id) {
    return new Promise(function(resolve, reject) {
        models.users.find({
            where: {
                facebook_id: id
            }
        }).success(function(user) {
            resolve(user.dataValues);
        }).error(reject);
    });
}

{'fraction_non_alphanumeric': 0.12531691416153568, 'fraction_numerical': 0.0007243752263672582, 'mean_word_length': 2.3724053724053724, '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': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4924270', 'n_tokens_mistral': 760, 'n_tokens_neox': 751, 'n_words': 218}