<commit_before>/**
 * FCO LOI User Management
 * Registration Controller
 *
 *
 */

var async = require('async'),
    crypto = require('crypto'),
    Model = require('../model/models.js'),
    ValidationService = require('../services/ValidationService.js'),  common = require('../../config/common.js'),
    envVariables = common.config();

var phonePattern = /([0-9]|[\-+#() ]){6,}/;


module.exports.showAccount = function(req, res) {
    Model.User.findOne({where:{email:req.session.email}}).then(function(user) {
        Model.AccountDetails.findOne({where:{user_id:user.id}}).then(function(account){
            if(account!==null) {
                return res.render('account_pages/account.ejs', {
                    user: user,
                    account: account,
                    url: envVariables,
                    info: req.flash('info'),
                    company_info: req.flash('company_info')
                });
            }else{
                return res.redirect('/api/user/complete-details');
            }
        });
    });
};

module.exports.showAddresses = function(req, res) {
    if(req.session.email) {
        Model.User.findOne({where: {email: req.session.email}}).then(function (user) {
            Model.AccountDetails.findOne({where: {user_id: user.id}}).then(function (account) {
                Model.SavedAddress.findAll({where: {user_id: user.id}}).then(function (addresses) {
                    return res.render('account_pages/addresses.ejs', {
                        user: user,
                        account: account,
                        url: envVariables,
                        addresses: addresses,
                        info: req.flash('info')
                    });
                });
            });
        });
    }
};
<commit_msg>Add ordering to the query which finds all addresses associated with a user<commit_after>/**
 * FCO LOI User Management
 * Registration Controller
 *
 *
 */

var async = require('async'),
    crypto = require('crypto'),
    Model = require('../model/models.js'),
    ValidationService = require('../services/ValidationService.js'),  common = require('../../config/common.js'),
    envVariables = common.config();

var phonePattern = /([0-9]|[\-+#() ]){6,}/;


module.exports.showAccount = function(req, res) {
    Model.User.findOne({where:{email:req.session.email}}).then(function(user) {
        Model.AccountDetails.findOne({where:{user_id:user.id}}).then(function(account){
            if(account!==null) {
                return res.render('account_pages/account.ejs', {
                    user: user,
                    account: account,
                    url: envVariables,
                    info: req.flash('info'),
                    company_info: req.flash('company_info')
                });
            }else{
                return res.redirect('/api/user/complete-details');
            }
        });
    });
};

module.exports.showAddresses = function(req, res) {
    if(req.session.email) {
        Model.User.findOne({where: {email: req.session.email}}).then(function (user) {
            Model.AccountDetails.findOne({where: {user_id: user.id}}).then(function (account) {
                Model.SavedAddress.findAll({where: {user_id: user.id}, order: [['id', 'ASC']]}).then(function (addresses) {
                    return res.render('account_pages/addresses.ejs', {
                        user: user,
                        account: account,
                        url: envVariables,
                        addresses: addresses,
                        info: req.flash('info')
                    });
                });
            });
        });
    }
};

{'fraction_non_alphanumeric': 0.15532664678774735, 'fraction_numerical': 0.001626457034426674, 'mean_word_length': 1.7996965098634294, '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': '231253', 'n_tokens_mistral': 1021, 'n_tokens_neox': 980, 'n_words': 161}