Skip to content

Commit

Permalink
Merge pull request #1 from oslabs-beta/junaid-aws
Browse files Browse the repository at this point in the history
commented out unnessacary console logs
  • Loading branch information
junaid-ahmed7 authored Mar 29, 2023
2 parents 89e5434 + b86d1e2 commit a4f76c9
Show file tree
Hide file tree
Showing 14 changed files with 236 additions and 212 deletions.
2 changes: 1 addition & 1 deletion backend/DummyD/dummyDataMain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const getRandomInt = (min: number, max: number) => {
const generateDataByType = (columnObj: ColumnObj): string | number => {
let length;
// faker.js method to generate data by type
console.log('columnObj_datatype: ', columnObj.data_type)
// console.log('columnObj_datatype: ', columnObj.data_type)

switch (columnObj.data_type) {
case 'smallint':
Expand Down
8 changes: 4 additions & 4 deletions backend/Logging/masterlog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,10 @@ const logger = function (
if (opt1) moreText += JSON.stringify(opt1);
if (opt2) moreText += JSON.stringify(opt2);

console.log(
`\u001b[1;${colorCode}m ${`[${logType}] ${message + moreText}`}` +
`\u001b[1;0m`
);
// console.log(
// `\u001b[1;${colorCode}m ${`[${logType}] ${message + moreText}`}` +
// `\u001b[1;0m`
// );
saveLogMessage(`[${logType}] ${message}`);
};

Expand Down
22 changes: 11 additions & 11 deletions backend/channels.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ ipcMain.handle(

event.sender.send('async-started');
try {
console.log('dbName from backend', dbName, 'dbType from backend');
// console.log('dbName from backend', dbName, 'dbType from backend');

await db.connectToDB(dbName, dbType);

Expand Down Expand Up @@ -199,7 +199,7 @@ ipcMain.handle(
const dumpCmd = withData
? runFullCopyFunc(sourceDb, tempFilePath, dbType)
: runHollowCopyFunc(sourceDb, tempFilePath, dbType);
console.log('dbType for importing a database', dbType);
// console.log('dbType for importing a database', dbType);
try {
await promExecute(dumpCmd);
} catch (e) {
Expand Down Expand Up @@ -334,7 +334,7 @@ ipcMain.handle(
null,
dbType
);
console.log(LogType.WARNING, results);
// console.log(LogType.WARNING, results);
explainResults = results[1].rows;
} else if (dbType === DBType.MySQL) {
const results = await db.query(
Expand All @@ -345,7 +345,7 @@ ipcMain.handle(
explainResults = results[0][0];
// console.log('mysql explain results', explainResults);

console.log(LogType.WARNING, results);
// console.log(LogType.WARNING, results);
}
} catch (e) {
error = `Failed to get Execution Plan. EXPLAIN might not support this query.`;
Expand All @@ -358,7 +358,7 @@ ipcMain.handle(
if (dbType === DBType.MySQL) {
returnedRows = results[0][1];

console.log('returnedRows in channels for MySQL', returnedRows);
// console.log('returnedRows in channels for MySQL', returnedRows);
}
if (dbType === DBType.Postgres) {
// console.log('results in channels for Postgres', results);
Expand Down Expand Up @@ -446,24 +446,24 @@ ipcMain.handle( // generate dummy data
logger("Received 'generate-dummy-data'", LogType.RECEIVE);
// send notice to front end that DD generation has been started
event.sender.send('async-started');
console.log('genereatedata ipcMain dbType: ', dbType)
// console.log('genereatedata ipcMain dbType: ', dbType)
let feedback: Feedback = {
type: '',
message: '',
};
try {
console.log('data in generate-dummy-data', data); // gets here fine
// console.log('data in generate-dummy-data', data); // gets here fine

// Retrieves the Primary Keys and Foreign Keys for all the tables
const tableInfo: ColumnObj[] = await db.getTableInfo(data.tableName, dbType); // passed in dbType to second argument
console.log('tableInfo in generate-dummy-data', tableInfo); // working
// console.log('tableInfo in generate-dummy-data', tableInfo); // working

// generate dummy data
const dummyArray: DummyRecords = await generateDummyData(
tableInfo,
data.rows
);
console.log('dummyArray output: ', dummyArray)
// console.log('dummyArray output: ', dummyArray)
// generate insert query string to insert dummy records
const columnsStringified = '('
.concat(dummyArray[0].join(', '))
Expand Down Expand Up @@ -495,10 +495,10 @@ ipcMain.handle( // generate dummy data
message: err,
};
} finally {
console.log('dbType inside generate-dummy-data', dbType)
// console.log('dbType inside generate-dummy-data', dbType)
// send updated db info in case query affected table or database information
const dbsAndTables: DBList = await db.getLists('', dbType); // dummy data clear error is from here
console.log('dbsAndTables in generate-dummy-data', dbsAndTables)
// console.log('dbsAndTables in generate-dummy-data', dbsAndTables)
event.sender.send('db-lists', dbsAndTables); // dummy data clear error is from here

// send feedback back to FE
Expand Down
32 changes: 16 additions & 16 deletions backend/helperFunctions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ const helperFunctions: HelperFunctions = {
const PG = `CREATE DATABASE "${name}"`;
const MYSQL = `CREATE DATABASE ${name}`;

console.log('RETURNING DB: ', DBType.Postgres ? PG : MYSQL);
console.log(dbType);
// console.log('RETURNING DB: ', DBType.Postgres ? PG : MYSQL);
// console.log(dbType);

return dbType === DBType.Postgres ? PG : MYSQL;
},
Expand All @@ -45,8 +45,8 @@ const helperFunctions: HelperFunctions = {
const PG = `DROP DATABASE "${dbName}"`;
const MYSQL = `DROP DATABASE ${dbName}`;

console.log(`dropDBFunc MySQL: ${MYSQL}, ${dbType}`);
console.log(`dropDBFunc PG: ${MYSQL}, ${dbType}`);
// console.log(`dropDBFunc MySQL: ${MYSQL}, ${dbType}`);
// console.log(`dropDBFunc PG: ${MYSQL}, ${dbType}`);

return dbType === DBType.Postgres ? PG : MYSQL;
},
Expand All @@ -56,22 +56,22 @@ const helperFunctions: HelperFunctions = {
const PG = `BEGIN; EXPLAIN (FORMAT JSON, ANALYZE, VERBOSE, BUFFERS) ${sqlString}; ROLLBACK`;
const MYSQL = `BEGIN; EXPLAIN ANALYZE ${sqlString}`;

console.log(`explainQuery MySQL: ${MYSQL}, ${dbType}`);
console.log(`explainQuery PG: ${MYSQL}, ${dbType}`);
// console.log(`explainQuery MySQL: ${MYSQL}, ${dbType}`);
// console.log(`explainQuery PG: ${MYSQL}, ${dbType}`);

return dbType === DBType.Postgres ? PG : MYSQL;
},

// import SQL file into new DB created
runSQLFunc: function (dbName, file, dbType: DBType) {
const SQL_data = docConfig.getFullConfig();
console.log(SQL_data)
// console.log(SQL_data)
const PG = `PGPASSWORD=${SQL_data.pg_pass} psql -U ${SQL_data.pg_user} -d "${dbName}" -f "${file}" -p ${SQL_data.pg_port}`;
// const MYSQL = `mysql -u root -p ${dbName} < ${file}`;
const MYSQL = `export MYSQL_PWD='${SQL_data.mysql_pass}'; mysql -u${SQL_data.mysql_user} --port=${SQL_data.mysql_port} ${dbName} < ${file}`;

console.log(`runSQLFunc MySQL: ${MYSQL}, ${dbType}`);
console.log(`runSQLFunc PG: ${PG}, ${dbType}`);
// console.log(`runSQLFunc MySQL: ${MYSQL}, ${dbType}`);
// console.log(`runSQLFunc PG: ${PG}, ${dbType}`);

return dbType === DBType.Postgres ? PG : MYSQL;
},
Expand All @@ -82,8 +82,8 @@ const helperFunctions: HelperFunctions = {
const PG = `PGPASSWORD=${SQL_data.pg_pass} pg_restore -U ${SQL_data.pg_user} -p ${SQL_data.pg_port} -d "${dbName}" "${file}" `;
const MYSQL = `export MYSQL_PWD='${SQL_data.mysql_pass}'; mysqldump -u ${SQL_data.mysql_user} --port=${SQL_data.mysql_port} ${dbName} > ${file}`;

console.log(`runTARFunc MySQL: ${MYSQL}, ${dbType}`);
console.log(`runTARFunc PG: ${PG}, ${dbType}`);
// console.log(`runTARFunc MySQL: ${MYSQL}, ${dbType}`);
// console.log(`runTARFunc PG: ${PG}, ${dbType}`);

return dbType === DBType.Postgres ? PG : MYSQL;
},
Expand All @@ -94,8 +94,8 @@ const helperFunctions: HelperFunctions = {
const PG = `PGPASSWORD=${SQL_data.pg_pass} pg_dump -s -U ${SQL_data.pg_user} -p ${SQL_data.pg_port} -Fp -d ${dbCopyName} > "${newFile}"`;
const MYSQL = `export MYSQL_PWD='${SQL_data.mysql_pass}'; mysqldump -h localhost -u ${SQL_data.mysql_user} ${dbCopyName} > ${newFile}`;

console.log(`runFullCopyFunc MySQL: ${MYSQL}, ${dbType}`);
console.log(`runFullCopyFunc PG: ${PG}, ${dbType}`);
// console.log(`runFullCopyFunc MySQL: ${MYSQL}, ${dbType}`);
// console.log(`runFullCopyFunc PG: ${PG}, ${dbType}`);

return dbType === DBType.Postgres ? PG : MYSQL;
},
Expand All @@ -106,8 +106,8 @@ const helperFunctions: HelperFunctions = {
const PG = ` PGPASSWORD=${SQL_data.pg_pass} pg_dump -s -U ${SQL_data.pg_user} -p ${SQL_data.pg_port} -F p -d "${dbCopyName}" > "${file}"`;
const MYSQL = `export MYSQL_PWD='${SQL_data.mysql_pass}'; mysqldump -h localhost -u ${SQL_data.mysql_user} --port=${SQL_data.mysql_port} ${dbCopyName} > ${file}`;

console.log(`runHollowCopyFunc MySQL: ${MYSQL}, ${dbType}`);
console.log(`runHollowCopyFunc PG: ${PG}, ${dbType}`);
// console.log(`runHollowCopyFunc MySQL: ${MYSQL}, ${dbType}`);
// console.log(`runHollowCopyFunc PG: ${PG}, ${dbType}`);
return dbType === DBType.Postgres ? PG : MYSQL;
},

Expand All @@ -116,7 +116,7 @@ const helperFunctions: HelperFunctions = {
new Promise((resolve, reject) => {
exec(cmd, {timeout: 5000}, (error, stdout, stderr) => {
if (error){
console.log(error)
// console.log(error)
return reject(error)};
if (stderr) return reject(new Error(stderr));
return resolve({ stdout, stderr });
Expand Down
14 changes: 7 additions & 7 deletions backend/models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ const getDBLists = function (
const tableList: TableDetails[] = [];
const promiseArray: Promise<ColumnObj[]>[] = [];

console.log('dbType - getDBLists: ', dbType);
// console.log('dbType - getDBLists: ', dbType);


if (dbType === DBType.Postgres) {
Expand Down Expand Up @@ -325,7 +325,7 @@ const PG_DBConnect = async function (pg_uri: string, db: string) {
};

const MSQL_DBConnect = function (db: string) {
console.log(`mysql dbconnect ${db}`);
// console.log(`mysql dbconnect ${db}`);
msql_pool
.query(`USE ${db};`)
.then(() => {
Expand Down Expand Up @@ -416,7 +416,7 @@ const myObj: MyObj = {
resolve(data);
})
.catch((err) => {
console.log(`Double: ${this.curMSQL_DB}`);
// console.log(`Double: ${this.curMSQL_DB}`);
logger(err.message, LogType.WARNING, 'dbQuery1');
reject(err);
});
Expand All @@ -429,7 +429,7 @@ const myObj: MyObj = {
resolve(data);
})
.catch((err) => {
console.log(`Double none: ${this.curMSQL_DB}`);
// console.log(`Double none: ${this.curMSQL_DB}`);
logger(err.message, LogType.WARNING, 'mysql caught');
reject(err);
});
Expand Down Expand Up @@ -459,7 +459,7 @@ const myObj: MyObj = {
this.curPG_DB = db;
await PG_DBConnect(this.pg_uri, db);
} else if (dbType === DBType.MySQL) {
console.log(`connectToDB -- : ${this.curMSQL_DB}`);
// console.log(`connectToDB -- : ${this.curMSQL_DB}`);
this.curMSQL_DB = db;
await MSQL_DBConnect(db);
}
Expand Down Expand Up @@ -505,7 +505,7 @@ const myObj: MyObj = {
})
.finally(() => {
if (dbType) {
console.log('dbType is defined')
// console.log('dbType is defined')
getDBLists(dbType, dbName) // dbLists returning empty array - DBType is not defined
.then((data) => {
logger(
Expand All @@ -522,7 +522,7 @@ const myObj: MyObj = {
);
});
} else {
console.log('dbType is not defined')
// console.log('dbType is not defined')
logger('RESOLVING DB DETAILS: Only DB Names', LogType.SUCCESS);
resolve(listObj);
}
Expand Down
2 changes: 1 addition & 1 deletion frontend/components/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ const App = () => {
const [showConfigDialog, setConfigDialog] = useState(false);

useEffect(() => {
console.log('dbTables:', dbTables, 'selectedTable: ', selectedTable, 'selectedDb: ', selectedDb, 'curDBType: ', curDBType, 'DBInfo: ', DBInfo, 'PG_isConnected: ', PG_isConnected, 'MYSQL_isConnected: ', MYSQL_isConnected);
// console.log('dbTables:', dbTables, 'selectedTable: ', selectedTable, 'selectedDb: ', selectedDb, 'curDBType: ', curDBType, 'DBInfo: ', DBInfo, 'PG_isConnected: ', PG_isConnected, 'MYSQL_isConnected: ', MYSQL_isConnected);
// Listen to backend for updates to list of available databases
const dbListFromBackend = (evt: IpcRendererEvent, dbLists: DbLists) => {
if (isDbLists(dbLists)) {
Expand Down
Loading

0 comments on commit a4f76c9

Please sign in to comment.