Skip to content

Commit 919124e

Browse files
committed
Cleaned up code
Co-authored-by: Jon Cruz <[email protected]> Co-authored-by: Elena Atencio <[email protected]> Co-authored-by: John Donato <[email protected]>
1 parent 2b975c2 commit 919124e

File tree

2 files changed

+10
-41
lines changed

2 files changed

+10
-41
lines changed

electron/databases/postgres.ts

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ const connectSQL = async (i: number, URI: string) => {
77
})
88
const client = await pool.connect();
99
client.release()
10+
console.log('connected to sql')
1011
return pool;
1112
} catch (err) {
1213
console.log('Error connecting to SQL')

electron/routes/data.ts

+9-41
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ ipcMain.on('connect', async (message: Electron.IpcMainEvent, username: string, i
7070
console.log('Connected to user provided MongoDB database')
7171
message.sender.send('databaseConnected', true);
7272
} else {
73-
console.log('Failed to connect to databse')
73+
console.log('Failed to connect to database')
7474
message.sender.send('databaseConnected', false);
7575
}
7676
})
@@ -85,43 +85,6 @@ ipcMain.on('connect', async (message: Electron.IpcMainEvent, username: string, i
8585
message.sender.send('databaseConnected', false);
8686
}
8787
}
88-
89-
90-
91-
// try{
92-
// // set database type from parameter
93-
// currentDatabaseType = databaseType;
94-
// console.log('Database type: ', databaseType);
95-
// if(currentDatabaseType === 'MongoDB'){
96-
// // First check if there is already an established mongoose connection with another databse...
97-
// // const isConnected = mongoose.connection.readyState === 1;
98-
// // if (isConnected){
99-
// // console.log('A connection to a mongoDB has already been established. Closing connection.');
100-
// mongoose.connection.close((error) => {
101-
// if(error) {
102-
// console.log('Error closing mongoDB connection: ', error);
103-
// }
104-
// });
105-
// // }
106-
// console.log('Database connection not found. Establishing connection...');
107-
// // Connect to the proper database
108-
// mongoose.connect(URI, { useNewUrlParser: true, useUnifiedTopology: true })
109-
// .then(() => {
110-
// console.log('Connected to user provided mongo database!');
111-
// message.sender.send('databaseConnected', true);
112-
// })
113-
// .catch(error => {
114-
// console.log('Error connecting to MongoDB inside data.ts connection:', error);
115-
// });
116-
// } else if (currentDatabaseType === 'SQL'){
117-
// // has not been reconfigured to handle different requests to SQL databses.
118-
// pool = await connectPostgres(index, URI);
119-
// message.sender.send('databaseConnected', true);
120-
// }
121-
// } catch(err){
122-
// message.sender.send('databaseConnected', false);
123-
// console.log('Error connecting to databse: ', err);
124-
// }
12588
});
12689

12790
/**
@@ -202,17 +165,22 @@ ipcMain.on('healthRequest', async (message: Electron.IpcMainEvent, service: stri
202165

203166
// SQL Database
204167
if (currentDatabaseType === 'SQL') {
168+
console.log('inside healthRequest call')
205169
// Get last 50 documents. If less than 50 get all
206170
result = await postgresFetch(service, pool);
171+
// const query = `SELECT * FROM services`;
172+
// result = await pool.query(query);
173+
// result = result.rows;
207174
}
208-
175+
console.log('result', result)
209176
// Async event emitter - send response'
210177

211178
message.sender.send('healthResponse', JSON.stringify(result));
212179
} catch (error) {
213180
// Catch errors
214-
console.log('Error in "healthRequest" event', message);
215-
message.sender.send('healthResponse', {});
181+
console.log('error sending result to healthresponse in healthrequest')
182+
// console.log(' event', message);
183+
// message.sender.send('healthResponse', {});
216184
}
217185
});
218186

0 commit comments

Comments
 (0)