-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
phu.phan
committed
Apr 9, 2024
1 parent
029707d
commit df059e5
Showing
8 changed files
with
203 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
const {faker} = require("@faker-js/faker") | ||
|
||
function createRanbdomUser(){ | ||
return { | ||
id:faker.string.uuid(), | ||
manager_id: faker.string.uuid(), | ||
azure_id: faker.string.uuid(), | ||
slack_id: faker.string.uuid(), | ||
role: "ADMIN", | ||
type:"REMOTE", | ||
name: faker.internet.userName(), | ||
address: faker.location.streetAddress(), | ||
group:"MEDIBA", | ||
company_phone_number: "81-3-6825-0189", | ||
department: "IT", | ||
position: "STAFF", | ||
area_code: "76", | ||
office_name:"Vietlink" | ||
} | ||
} | ||
|
||
function createUser() { | ||
const user = faker.helpers.multiple(createRanbdomUser, { | ||
count: 1000, | ||
}); | ||
return user; | ||
|
||
} | ||
|
||
module.exports = { | ||
createUser, | ||
} |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
export enum Emergency { | ||
TSUNAMI = "TSUNAMIS", | ||
EARTHQUAKES = "EARTHQUAKES", | ||
} | ||
|
||
function CallbackInterval(type, time, listAlert) { | ||
// check is reponse --> update resposne | ||
// clear to array user not response | ||
// next send interval | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
var mysql = require('mysql'); | ||
var connection = mysql.createConnection({ | ||
host : 'localhost', | ||
user : 'phankieuphu', | ||
password : 'phankieuphu123', | ||
database : 'nestdemo', | ||
port:3306 | ||
}); | ||
|
||
|
||
module.exports = connection; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"dependencies": { | ||
"@faker-js/faker": "^8.4.1", | ||
"mysql": "^2.18.1" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
const fs = require('fs'); | ||
const {createUser} = require('./faker') | ||
// Function to generate SQL insert statements for an array of users | ||
console.time('generateInsertStatements') | ||
function generateInsertStatements(users) { | ||
let sqlStatements = ''; | ||
sqlStatements += `INSERT INTO users (id, manager_id, azure_id, slack_id, role, type, name, address, \`group\`, company_phone_number, department, position, area_code, office_name) VALUES `; | ||
// Iterate over each user and generate insert statement | ||
users.forEach(user => { | ||
const values = Object.values(user).map(value => { | ||
// If value is a string, escape single quotes | ||
if (typeof value === 'string') { | ||
return "'" + value.replace(/'/g, "''") + "'"; | ||
} | ||
return value; | ||
}).join(', '); | ||
sqlStatements += `(${values}) , ` | ||
|
||
}); | ||
|
||
return sqlStatements + ';'; | ||
} | ||
console.timeEnd("generateInsertStatements"); | ||
// Function to write SQL insert statements to a file | ||
function writeInsertStatementsToFile(insertStatements, fileName) { | ||
fs.writeFileSync(fileName, insertStatements); | ||
console.log(`SQL insert statements have been written to ${fileName}`); | ||
} | ||
|
||
// Example usage | ||
const insertStatements = generateInsertStatements(createUser()); // Generate SQL insert statements | ||
writeInsertStatementsToFile(insertStatements, 'insert_users.sql'); // Write insert statement |