Skip to content

Commit adc5468

Browse files
committed
Code clean-up
1 parent aee73e4 commit adc5468

24 files changed

+34
-184
lines changed

app.mjs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import express from 'express';
2-
// import { engine } from 'express-handlebars';
32
import exphbs from 'express-handlebars';
43
import path from "path";
54
import session from "express-session";

controllers/apiController.mjs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import multer from 'multer';
21
import * as model from '../model/dbInterface.js';
32
import { formatDate } from '../public/scripts/formatDate.js';
43

controllers/bookingCompleteController.mjs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,6 @@ async function getBookingComplete(req, res, next) {
102102

103103
// get current timestamp
104104
const date_booked = new Date().toISOString().slice(0, 19).replace('T', ' ');
105-
// console.log("discountID", discountID, "categoryID", categoryID, "showID", showID, "date_booked", date_booked, "userID", req.session.loggedUserId);
106105

107106
const lastInsertedTicketID = await model.insertTicket(ticket.ticketNumber, 'BOOKED', categoryID, req.session.loggedUserId, date_booked, discountID, showID);
108107
// destroy the booking token

controllers/bookingController.mjs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ async function bookingTheater(eventID, req, res, next) {
88
model.getTheaterEventInfo(eventID, (err, eventInfo) => {
99
if (err) {
1010
const error_comment = "Could not get theater event info from the database";
11-
// pass the comment to the session?
11+
req.session.error_comment = error_comment;
1212
console.error(error_comment);
1313
next(err);
1414
}
@@ -28,7 +28,7 @@ async function bookingTheater(eventID, req, res, next) {
2828
model.getEventReviews(eventID, (err, reviewList) => {
2929
if (err) {
3030
const error_comment = "Could not get reviews from the database"
31-
// pass the comment to the session?
31+
req.session.error_comment = error_comment;
3232
console.error(error_comment);
3333
next(err);
3434
}
@@ -46,7 +46,7 @@ async function bookingTheater(eventID, req, res, next) {
4646
model.getShowInfo(eventID, (err, showList) => {
4747
if (err) {
4848
const error_comment = "Could not get show info from the database";
49-
// pass the comment to the session?
49+
req.session.error_comment = error_comment;
5050
console.error(error_comment);
5151
next(err);
5252
}
@@ -100,7 +100,7 @@ async function bookingTheater(eventID, req, res, next) {
100100
model.getModalInfo(eventID, (err, seatingCatList) => {
101101
if (err) {
102102
const error_comment = "Could not get modal info from the database";
103-
// pass the comment to the session?
103+
req.session.error_comment = error_comment;
104104
console.error(error_comment);
105105
next(err);
106106
}
@@ -137,7 +137,7 @@ async function bookingMusic(eventID, req, res, next) {
137137
model.getMusicEventInfo(eventID, (err, eventInfo) => {
138138
if (err) {
139139
const error_comment = "Could not get music event info from the database";
140-
// pass the comment to the session?
140+
req.session.error_comment = error_comment;
141141
console.error(error_comment);
142142
next(err);
143143
}
@@ -156,7 +156,7 @@ async function bookingMusic(eventID, req, res, next) {
156156
model.getEventReviews(eventID, (err, reviewList) => {
157157
if (err) {
158158
const error_comment = "Could not get reviews from the database"
159-
// pass the comment to the session?
159+
req.session.error_comment = error_comment;
160160
console.error(error_comment);
161161
next(err);
162162
}
@@ -176,7 +176,7 @@ async function bookingMusic(eventID, req, res, next) {
176176
model.getShowInfo(eventID, (err, showList) => {
177177
if (err) {
178178
const error_comment = "Could not get show info from the database";
179-
// pass the comment to the session?
179+
req.session.error_comment = error_comment;
180180
console.error(error_comment);
181181
next(err);
182182
}
@@ -231,7 +231,7 @@ async function bookingMusic(eventID, req, res, next) {
231231
model.getModalInfo(eventID, (err, seatingCatList) => {
232232
if (err) {
233233
const error_comment = "Could not get modal info from the database";
234-
// pass the comment to the session?
234+
req.session.error_comment = error_comment;
235235
console.error(error_comment);
236236
next(err);
237237
}

controllers/eventsController.mjs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ async function theaterEvents(navigateTo, req, res, next) {
4949
carouselEventList[i].titleU = carouselEventList[i].title.toUpperCase();
5050
carouselEventList[i].type = navigateTo;
5151
}
52-
// res.json(eventList);
5352
res.render('events', { site_header, eventList, carouselEventList });
5453
});
5554
}
@@ -108,7 +107,6 @@ async function musicEvents(navigateTo, req, res, next) {
108107
carouselEventList[i].titleU = carouselEventList[i].title.toUpperCase();
109108
carouselEventList[i].type = navigateTo;
110109
}
111-
// res.json(eventList);
112110
res.render('events', { site_header, eventList, carouselEventList });
113111

114112
});
@@ -171,7 +169,6 @@ async function cinemaEvents(navigateTo, req, res, next) {
171169
carouselEventList[i].titleU = carouselEventList[i].title.toUpperCase();
172170
carouselEventList[i].type = navigateTo;
173171
}
174-
// res.json(eventList);
175172
res.render('events', { site_header, eventList, carouselEventList });
176173

177174
});

controllers/profileController.mjs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,14 +51,14 @@ let profileNavigation = async function (req, res, next) {
5151

5252
let timeString = ticketList[i].show_time;
5353

54-
// Split the time string into hours, minutes, and seconds
54+
// split the time string into hours, minutes, and seconds
5555
let [hours, minutes, seconds] = timeString.split(':');
5656

57-
// Convert the hours to a 12-hour format with AM/PM indication
57+
// convert the hours to a 12-hour format with AM/PM indication
5858
let ampm = hours >= 12 ? 'pm' : 'am';
5959
hours = (hours % 12) || 12;
6060

61-
// Construct the formatted time string
61+
// construct the formatted time string
6262
let formattedTime = hours + ':' + minutes + ' ' + ampm;
6363

6464
ticketList[i].show_time = formattedTime;

controllers/reviewsController.mjs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,7 @@ let reviewsNavigation = async function (req, res, next) {
2626

2727
// Format the date components
2828
reviewDate = new Date(review.date_written);
29-
30-
// Format the date components
3129
formattedDate = reviewDate.getDate().toString().padStart(2, '0') + '-' + (reviewDate.getMonth() + 1).toString().padStart(2, '0') + '-' + reviewDate.getFullYear().toString();
32-
3330
review.date_written = formattedDate;
3431

3532

model/SQL/queries.js

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -133,14 +133,6 @@ JOIN "VENUE" v ON v."venueID" = es."venueID"
133133
WHERE e."eventID" = $1 AND es."status" = 'SCHEDULED'
134134
ORDER BY es."show_date"`
135135

136-
// `SELECT es."showID", es."venueID", cat."categoryID", es."status", vsc."seat_num", sp."seat_price", cat."category_name"
137-
// FROM "EVENT_SHOW" es
138-
// JOIN "Venue_HAS_Seat_Cat" vsc ON es."venueID" = vsc."venueID"
139-
// JOIN "SEAT_CATEGORY" cat ON cat."categoryID" = vsc."categoryID"
140-
// JOIN "Sets_Price" sp ON es."showID" = sp."showID" --AND cat."categoryID" = sp."categoryID"
141-
// WHERE es."showID" = 4 and es."status" = 'SCHEDULED'`
142-
143-
144136
const getUserInfo = `SELECT * FROM "USER" u
145137
WHERE u."userID" = $1`
146138

@@ -220,9 +212,6 @@ FROM "USER" u
220212
WHERE (u."username" = $1 OR u."email" = $2)
221213
LIMIT 1;`
222214

223-
224-
225-
226215
const insertTicket = `INSERT INTO "TICKET"(
227216
"ticket_number", "status", "categoryID", "userID", "date_booked", "discountID", "showID")
228217
VALUES ($1, $2, $3, $4, $5, $6, $7);`

model/dbInterface.js

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ async function connect() {
4646
}
4747
catch (e) {
4848
// console.error(`Failed to connect ${e}, with the second pool`);
49+
throw e;
4950
}
5051

5152
}
@@ -112,19 +113,6 @@ async function getAllCinema(callback) {
112113
}
113114
}
114115

115-
116-
// async function getEventShows(eventID, callback) {
117-
// try {
118-
// const client = await connect();
119-
// const res = await client.query(sql.getEventShows, [eventID])
120-
// await client.release()
121-
// callback(null, res.rows)
122-
// }
123-
// catch (err) {
124-
// callback(err, null);
125-
// }
126-
// }
127-
128116
async function getEventReviews(eventID, callback) {
129117
try {
130118
const client = await connect();
@@ -338,7 +326,6 @@ async function signUpUser(username, password, fullName, email, registrationDate,
338326
const client = await connect();
339327
await client.query(sql.signUpUser, [username, hashedPassword, fullName, email, registrationDate, profile_imageURL]);
340328
client.release();
341-
// let message = `User ${username} created succesfully`;
342329
return { message: `User ${username} created succesfully!` };
343330
}
344331
catch (error) {

public/css/rating-system.css

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
/* ------- STAR RATING SYSTEM ------- */
22
.ratings-wrapper{
3-
/* border: thin solid #999; */
43
display: inline-block;
54
margin-bottom: 0.25em;
65
}

public/css/search-bar.css

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111

1212
.main-menu-search-bar #search-results {
1313
position:absolute;
14-
/* background-color:brown; */
1514
width: 30%;
1615
top: 42%;
1716
left: 33.3%;

0 commit comments

Comments
 (0)