<commit_before>'use strict'

//Import modules
const sequelize = require('sequelize')
const express = require ('express')
const bcrypt = require ('bcrypt-nodejs')

//define module

const db = {}
// Connect to database
db.conn = new sequelize ('goalify', process.env.POSTGRES_USER, process.env.POSTGRES_PASSWORD, {
	server: 'localhost',
	dialect: 'postgres'
})

// Define database structure

//// Define models
db.User = db.conn.define( 'user', {
	username: sequelize.STRING,
	email: { type: sequelize.STRING, unique: true },
	password: sequelize.STRING,
	score: sequelize.INTEGER,
	dob: sequelize.DATEONLY,
	kindOfPerson: sequelize.STRING
} )
db.Goal = db.conn.define ('goal', {
	title: sequelize.STRING,
	description: sequelize.STRING,
	duration: sequelize.INTEGER,
	difficulty: sequelize.STRING,
	points: sequelize.INTEGER,
	geolocation: sequelize.STRING
})
// var point = { type: 'Point', coordinates: [52.374336, 4.912338]};
db.Complete = db.conn.define ('complete', {
	geolocation: sequelize.STRING
})

//// Define relations
db.User.hasMany( db.Complete )
db.Complete.belongsTo ( db.User )
db.Goal.hasMany( db.Complete)
db.Complete.belongsTo (db.Goal)

db.conn.sync( {force: true}).then( () => {
		
	//Create sample user
	bcrypt.hash('panda123', null, null, function(err, hash) {
		if (err) throw (err); 

		db.User.create( {
			username: 'selma2202',
			email: '<EMAIL>',
			password: <PASSWORD>,
			score: 20,
			dob: '1991-02-22',
			kindOfPerson: 'catperson'
		})
		.then ( user => {
			user.createComplete ( {
			})
		})
	})

	//Create sample goal
	db.Goal.create( {
		title: 'Run the stairs of Nemo',
		description: 'Start at the bottom, then run as fast as you can up the stairs of Nemo. Take a picture when you are at the top.',
		duration: 5,
		difficulty: 'easy',
		points: 10,
		geolocation: '[52.374336, 4.912338]'
	})
	.then ( goal => {
		goal.createComplete ({
			geolocation: '[52.374336, 4.912338]'
		}).then( complete => {

		} )
	})

	console.log ('Synced, yay')
})





//export defined module
module.exports = db<commit_msg>did not quite get promise.all to work, but apart from that, tables are filled with samples<commit_after>'use strict'

//Import modules
const sequelize = require('sequelize')
const express = require ('express')
const bcrypt = require ('bcrypt-nodejs')

//define module

const db = {}
// Connect to database
db.conn = new sequelize ('goalify', process.env.POSTGRES_USER, process.env.POSTGRES_PASSWORD, {
	server: 'localhost',
	dialect: 'postgres'
})

// Define database structure

//// Define models
db.User = db.conn.define( 'user', {
	username: sequelize.STRING,
	email: { type: sequelize.STRING, unique: true },
	password: sequelize.STRING,
	score: sequelize.INTEGER,
	dob: sequelize.DATEONLY,
	kindOfPerson: sequelize.STRING
} )
db.Goal = db.conn.define ('goal', {
	title: sequelize.STRING,
	description: sequelize.STRING,
	duration: sequelize.INTEGER,
	difficulty: sequelize.STRING,
	points: sequelize.INTEGER,
	geolocation: sequelize.STRING
})
// var point = { type: 'Point', coordinates: [52.374336, 4.912338]};
db.Complete = db.conn.define ('complete', {
	geolocation: sequelize.STRING
})

//// Define relations
db.User.hasMany( db.Complete )
db.Complete.belongsTo ( db.User )
db.Goal.hasMany( db.Complete)
db.Complete.belongsTo (db.Goal)

db.conn.sync( {force: true}).then( () => {

	//Create sample user
	bcrypt.hash('panda123', null, null, function(err, hash) {
		if (err) throw (err); 

		var p1 = db.User.create( {
			username: 'selma2202',
			email: '<EMAIL>',
			password: <PASSWORD>,
			score: 20,
			dob: '1991-02-22',
			kindOfPerson: 'catperson'
		})
		.then ( user => {
			user.createComplete ( {
				geolocation: '[52.374336, 4.912338]'
			})
		})

		//Create sample goal
		var p2 = db.Goal.create( {
			title: 'Run the stairs of Nemo',
			description: 'Start at the bottom, then run as fast as you can up the stairs of Nemo. Take a picture when you are at the top.',
			duration: 5,
			difficulty: 'easy',
			points: 10,
			geolocation: '[52.374336, 4.912338]'
		})
		.then ( goal => {
			goal.createComplete ({
				geolocation: '[52.374336, 4.912338]'
			}).then( complete => {

			} )
		})

		// Promise.all([p1.id, p2.id]).then (values => {
		// 	console.log(values)
		// 	values.createComplete ({
		// 		geolocation: '[52.374336, 4.912338]'
		// 	})
		// })
	})



	console.log ('Synced, yay')
})





//export defined module
module.exports = db
{'fraction_non_alphanumeric': 0.15893140140366765, 'fraction_numerical': 0.03712927326239529, 'mean_word_length': 3.6020833333333333, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 16, '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': '2805534', 'n_tokens_mistral': 1822, 'n_tokens_neox': 1552, 'n_words': 397}