Skip to content

Commit

Permalink
Merge pull request #93 from jbkuczma/develop
Browse files Browse the repository at this point in the history
Official release pt 2 #91
  • Loading branch information
deankostorowski authored Nov 19, 2017
2 parents 1b78814 + e46361d commit b515c13
Show file tree
Hide file tree
Showing 19 changed files with 164 additions and 405 deletions.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,8 @@ You should see the following prompt:

**Note**

There will be a slight delay on the room host's screen from when a user joins a room to them showing up in the "Users in room" area. There will also be a slight delay when selecting a song and having it show up in the queue. Rapidly adding songs to the queue may cause server overload which will then need to be restarted, forcing everyone to have to login again - be generous.
There will be a slight delay on the room host's screen from when a user joins a room to them showing up in the "Users in room" area. There will also be a slight delay when selecting a song and having it show up in the queue. Rapidly adding songs to the queue may cause server overload which will then need to be restarted, forcing everyone to have to login again - be generous.

**Commentary** (tbd)

Cool project, guys. - Wendy
5 changes: 5 additions & 0 deletions create_clean_db.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,14 @@ mysql -u ${USER} -p << SQL
song_name TEXT NOT NULL,
PRIMARY KEY (rank_in_queue)
);
CREATE TABLE IF NOT EXISTS previous_music (
room_code VARCHAR(5) NOT NULL,
song_name TEXT NOT NULL
);
INSERT INTO users (username, password, salt, created_at, current_room) VALUES ('test.1', 'f6537d74a07a61d7a7524e4f5d4070a3fffcdf51c72c6ee22792fd21d76aca388c08abab492790f91879731c427b1653f91e484386b951b61e1783a61732eeaf', '5fc0f38ea20272f8', NOW(), NULL);
INSERT INTO rooms (room_name, room_code, created_at, room_owner_name) VALUES ('SaturdaysAreForTheBoys', '4444', NOW(), 'test.1');
INSERT INTO music (youtube_id, room_code, song_name) VALUES ('Kp7eSUU9oy8', '4444', '3005');
INSERT INTO previous_music (room_code, song_name) VALUES (4444, 'Kanye West - Stronger');
SQL
echo "Finished creating database ${DB}";
else
Expand Down
24 changes: 12 additions & 12 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "moose",
"version": "0.2.0",
"version": "1.0.0",
"description": "UB CSE 442 project",
"main": "server.js",
"scripts": {
Expand Down
41 changes: 40 additions & 1 deletion server/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ app.get('/room/:roomCode/search', function(request,response){
let searchQuery = request.query.query;
let options = {
maxResults: 10,
type: 'video',
key: my_key.my_key
};

Expand All @@ -83,7 +84,7 @@ app.post('/song/add', function(request, response) {
let name = request.body.name;
let song = request.body.song;
let roomCode = request.body.room;
let sql = 'INSERT INTO music (youtube_id, room_code, song_name) VALUES (?, ?, ?); ';
let sql = 'INSERT INTO music (youtube_id, room_code, song_name) VALUES (?, ?, ?);';
connection.query(sql, [song, roomCode, name], function (error, results, fields) {
if (error) {
response.redirect('/rooms');
Expand All @@ -101,6 +102,38 @@ app.post('/song/remove', function(request, response) {
}
});
});

// add a song to the previously played songs for a room
app.post('/room/:roomCode/previous', function(request, response) {
let songName = request.body.songName;
let roomCode = request.params.roomCode;
let sql = 'INSERT INTO previous_music (room_code, song_name) VALUES (?, ?)';
connection.query(sql, [roomCode, songName], function(error, results, fields) {
if (error) {
response.redirect('/rooms');
}
});
});
// get previously played songs for a room
app.get('/room/:roomCode/previous', function(request, response) {
let roomCode = request.params.roomCode;
let sql = 'SELECT song_name FROM previous_music WHERE room_code=?';
connection.query(sql, roomCode, function(error, results, fields) {
if(results) {
let previousRoomMusic = results.map(function(row) {
return {
song: row['song_name']
};
});
previousRoomMusic = _.uniq(previousRoomMusic, function(v) {
return v.song
});
response.json({
'data': previousRoomMusic
});
}
});
});
// serve a specific room page
app.get('/room/:roomCode', function(request, response) {
if(!request.session.passport) {
Expand Down Expand Up @@ -308,6 +341,7 @@ app.post('/room/delete', function(request, response) {
let roomCode = request.body.room;
let SQL = 'DELETE FROM music WHERE music.room_code=?';
let SQL2 = 'DELETE FROM rooms WHERE rooms.room_code=?';
let SQL3 = 'DELETE FROM previous_music WHERE previous_music.room_code=?';
connection.query(SQL, roomCode, function (error, results, fields){
if (error) {
response.redirect('/rooms');
Expand All @@ -316,6 +350,11 @@ app.post('/room/delete', function(request, response) {
if (error) {
throw error;
}
connection.query(SQL3, roomCode, function (error, results, fields){
if (error) {
throw error;
}
});
});
});
});
Expand Down
1 change: 0 additions & 1 deletion www/css/bootstrap-grid.css.map

This file was deleted.

2 changes: 0 additions & 2 deletions www/css/bootstrap-grid.min.css

This file was deleted.

1 change: 0 additions & 1 deletion www/css/bootstrap-grid.min.css.map

This file was deleted.

Loading

0 comments on commit b515c13

Please sign in to comment.