<commit_before>/*
	user table:
		_id, account, password(<PASSWORD>), name, picture, google, facebook, fitbit, nikeplus, jawbone, runkeeper
 */
var crypto = require('crypto');

module.exports = function (EasyDB) {
    var init = function (EasyDB) {
        this.DB = EasyDB;
        return this;
    }
	// data = { account, password }
	// return = { _id, name, picture } || false
	, login = function (data) {
	    var db = this.DB;

	    var hash;
	    var account = data.account;
	    var password = data.password;

	    hash = crypto.createHash('sha1');
	    hash.update(password);
	    password = <PASSWORD>('<PASSWORD>');
	    var dbt = db.listData('users', "account=" + account).list[0];
	    if (dbt) {
	        var vpassword = <PASSWORD>;
	        if (vpassword == password) {
	            return { _id: dbt._id, name: dbt.name, picture: dbt.picture };
	        } else {
	            return false;
	        };
	    } else {
	        return false;
	    };
	}

	// data = { account, password }
	// return = _id || false (account exist)
	, add = function (data) {
	    var db = this.DB;

	    var hash;
	    var account = data.account;
	    var password = data.password;

	    hash = crypto.createHash('sha1');
	    hash.update(password);
	    password = <PASSWORD>('<PASSWORD>');
	    var dbt = db.listData('users', "account=" + account).list[0];
	    if (dbt) {
	        return false; // 'account exist';
	    } else {
	        db.postData('users', { account: account, password: password });
	        return { _id: dbt._id };
	    };
	}

	// data = { platform, userData }
	// return = _id || false (platform userData exist)
	, addByPlatform = function (data) {
	    var db = this.DB;

	    var platform = data.platform;
	    var userData = data.userData;

	    var dbt = db.listData('users', platform).list[0];
	    if (dbt) {
	        return false; // 'platform userData exist';
	    } else {

	        var dbj = '{ name: userData.data[0].name, picture: userData.data[0].picture, ' + platform + ': userData }';
	        db.postData('users', JSON.parse(dbj));

	        //switch (platform) {
	        //    case 'google':
	        //        db.postData('users', { name: userData.data[0].name, picture: userData.data[0].picture, google: userData });
	        //    case 'facebook':
	        //        db.postData('users', { name: userData.data[0].name, picture: userData.data[0].picture, facebook: userData });
	        //    case 'fitbit':
	        //    case 'nikeplus':
	        //    case 'jawbone':
	        //    case 'runkeeper':
	        //};
	        return { _id: dbt._id };
	    };
	}

	// data = { platform, userData }
	// return = { _id, name, picture } || false (not found)
	, findByPlatform = function (data) {
	    var db = this.DB;

	    var platform = data.platform;
	    var userData = data.userData;
	    var dbt = null;
	    switch (platform) {
	        case 'google':
	            dbt = db.listData('users', "google=" + userData).list[0];
	        case 'facebook':
	            dbt = db.listData('users', "facebook=" + userData).list[0];
	        case 'fitbit':
	        case 'nikeplus':
	        case 'jawbone':
	        case 'runkeeper':
	    };

	    if (dbt) {
	        return { _id: dbt._id, name: dbt.name, picture: dbt.picture };
	    } else {
	        return false; //'not found';
	    };
	}

	// data = _id
	// return = { _id, name, picture } || false (not found)
	, findByID = function (data) {
	    var db = this.DB;

	    var _id = data._id;

	    var dbt = db.listData('users', "_id=" + _id).list[0];
	    if (dbt) {
	        return { _id: dbt._id, name: dbt.name, picture: dbt.picture };
	    } else {
	        return false; // 'not found';
	    };
	}

	// data = { _id, platform, userData }
	// return = true || false (not found)
	, addToken = function (data) {
	    var db = this.DB;

	    var _id = data._id;
	    var platform = data.platform;
	    var userData = data.userData;

	    var dbt = db.listData('users', "_id=" + _id).list[0];
	    if (dbt) {
	        switch (platform) {
	            case 'google':
	                dbt = db.postData('users', { google: userData });
	            case 'facebook':
	                dbt = db.postData('users', { facebook: userData });
	            case 'fitbit':
	            case 'nikeplus':
	            case 'jawbone':
	            case 'runkeeper':
	        };
	        return true;
	    } else {
	        return false; // 'not found';
	    };
	}

	// data = _id
	// return = row data || false (not found)<commit_msg>Fix addByPlatform<commit_after>/*
	user table:
		_id, account, password(<PASSWORD>), name, picture, google, facebook, fitbit, nikeplus, jawbone, runkeeper
 */
var crypto = require('crypto');

module.exports = function (EasyDB) {
    var init = function (EasyDB) {
        this.DB = EasyDB;
        return this;
    }
	// data = { account, password }
	// return = { _id, name, picture } || false
	, login = function (data) {
	    var db = this.DB;

	    var hash;
	    var account = data.account;
	    var password = data.password;

	    hash = crypto.createHash('sha1');
	    hash.update(password);
	    password = hash.digest('hex');
	    var dbt = db.listData('users', "account=" + account).list[0];
	    if (dbt) {
	        var vpassword = dbt.password;
	        if (vpassword == password) {
	            return { _id: dbt._id, name: dbt.name, picture: dbt.picture };
	        } else {
	            return false;
	        };
	    } else {
	        return false;
	    };
	}

	// data = { account, password }
	// return = _id || false (account exist)
	, add = function (data) {
	    var db = this.DB;

	    var hash;
	    var account = data.account;
	    var password = data.password;

	    hash = crypto.createHash('sha1');
	    hash.update(password);
	    password = hash.digest('hex');
	    var dbt = db.listData('users', "account=" + account).list[0];
	    if (dbt) {
	        return false; // 'account exist';
	    } else {
	        db.postData('users', { account: account, password: password });
	        return { _id: dbt._id };
	    };
	}

	// data = { platform, userData }
	// return = _id || false (platform userData exist)
	, addByPlatform = function (data) {
	    var db = this.DB;

	    var platform = data.platform;
	    var userData = data.userData;

	    var dbt = db.listData('users', platform).list[0];
	    if (dbt) {
	        return false; // 'platform userData exist';
	    } else {

	        var dbj = { name: userData.data[0].name, picture: userData.data[0].picture };
	        dbj[platform] = userData;
	        db.postData('users', dbj);

	        return { _id: dbt._id };
	    };
	}

	// data = { platform, userData }
	// return = { _id, name, picture } || false (not found)
	, findByPlatform = function (data) {
	    var db = this.DB;

	    var platform = data.platform;
	    var userData = data.userData;

	    var dbj = {};
	    dbj[platform] = userData;
	    db.postData('users', dbj);

	    var dbt = listData('users', dbj).list[0];

	    if (dbt) {
	        return { _id: dbt._id, name: dbt.name, picture: dbt.picture };
	    } else {
	        return false; //'not found';
	    };
	}

	// data = _id
	// return = { _id, name, picture } || false (not found)
	, findByID = function (data) {
	    var db = this.DB;

	    var _id = data._id;

	    var dbt = db.listData('users', "_id=" + _id).list[0];
	    if (dbt) {
	        return { _id: dbt._id, name: dbt.name, picture: dbt.picture };
	    } else {
	        return false; // 'not found';
	    };
	}

	// data = { _id, platform, userData }
	// return = true || false (not found)
	, addToken = function (data) {
	    var db = this.DB;

	    var _id = data._id;
	    var platform = data.platform;
	    var userData = data.userData;

	    var dbt = db.listData('users', "_id=" + _id).list[0];
	    if (dbt) {
	        var dbj = {};
	        dbj[platform] = userData;
	        db.postData('users', dbj);	        
	        return true;
	    } else {
	        return false; // 'not found';
	    };
	}

	// data = _id
	// return = row data || false (not found)
{'fraction_non_alphanumeric': 0.1555389779932861, 'fraction_numerical': 0.0031082929255253017, 'mean_word_length': 1.9803630974434976, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 10, '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': '3690265', 'n_tokens_mistral': 2815, 'n_tokens_neox': 2577, 'n_words': 677}