<commit_before>/**
 * Created by YS on 2017-04-14.
 */

var authModel = {
    checkUserName : function(context, data) {
        return new Promise(function(resolved, rejected) {
            var select = [data.username];
            var sql = `SELECT admin_username
            	FROM admin_table 
            	WHERE admin_username = ? `;

            context.connection.query(sql, select, function (err, rows) {
                if (err) {
                    var error = new Error(err);
                    error.status = 500;
                    return rejected({ context : context, error : error });
                } else if (rows.length > 0) {
                	// TODO 아무것도 없는 경우
                    var error = new Error("exist user");
                    error.status = 9401;
                    return rejected({ context : context, error : error });
	            }
	            
            	return resolved(context);
            });
        });
    },

    createUser : function(context, data) {
    	return new Promise(function(resolved, rejected) {
    		var insert = [data.username, data.nickname, data.password];
    		var sql = `INSERT INTO admin_table SET
    			admin_username = ?,
    			nickname = ?,
    			admin_password = ? `;

			context.connection.query(sql, insert, function (err, rows) {
                if (err) {
                    var error = new Error(err);
                    error.status = 500;
                    return rejected({ context : context, error : error });
                }

                return resolved(context);
            });
    	})
    },

    checkUser : function(context, data) {
    	return new Promise(function(resolved, rejected) {<commit_msg>*fix mistake<commit_after>/**
 * Created by YS on 2017-04-14.
 */

var authModel = {
    checkUserName : function(context, data) {
        return new Promise(function(resolved, rejected) {
            var select = [data.username];
            var sql = `SELECT admin_username
            	FROM admin_table 
            	WHERE admin_username = ? `;

            context.connection.query(sql, select, function (err, rows) {
                if (err) {
                    var error = new Error(err);
                    error.status = 500;
                    return rejected({ context : context, error : error });
                } else if (rows.length > 0) {
                	// TODO 아무것도 없는 경우
                    var error = new Error("exist user");
                    error.status = 9401;
                    return rejected({ context : context, error : error });
	            }
	            
            	return resolved(context);
            });
        });
    },

    createUser : function(context, data) {
    	return new Promise(function(resolved, rejected) {
    		var temp = [];
    		temp.push(data.username, data.nickname);
    		var insert = [temp, data.password];
    		var sql = `INSERT INTO admin_table (admin_username, nickname, admin_password) VALUES
    			(?, ?) `;

			context.connection.query(sql, insert, function (err, rows) {
                if (err) {
                    var error = new Error(err);
                    error.status = 500;
                    return rejected({ context : context, error : error });
                }

                return resolved(context);
            });
    	})
    },

    checkUser : function(context, data) {
    	return new Promise(function(resolved, rejected) {
{'fraction_non_alphanumeric': 0.10661229245557821, 'fraction_numerical': 0.011069035828721235, 'mean_word_length': 1.4776334776334776, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '1505536', 'n_tokens_mistral': 962, 'n_tokens_neox': 881, 'n_words': 238}