From e9adf3007ce963fc2a94a00f9445d88d1670e3b1 Mon Sep 17 00:00:00 2001 From: Julio Biason Date: Thu, 5 Sep 2013 14:32:50 -0300 Subject: [PATCH] starting to mark songs as played --- lyricsnode/app.js | 1 + lyricsnode/routes/round.js | 20 ++++++++++++++++++-- lyricsnode/views/index.html | 2 +- 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/lyricsnode/app.js b/lyricsnode/app.js index 1415ec1..c792f38 100644 --- a/lyricsnode/app.js +++ b/lyricsnode/app.js @@ -37,6 +37,7 @@ if ('development' == app.get('env')) { app.get('/', round.index); app.post('/round/others/', round.others); +app.post('/round/played/', round.played); http.createServer(app).listen(app.get('port'), function(){ console.log('Express server listening on port ' + app.get('port')); diff --git a/lyricsnode/routes/round.js b/lyricsnode/routes/round.js index 0f7750f..84e40c4 100644 --- a/lyricsnode/routes/round.js +++ b/lyricsnode/routes/round.js @@ -133,7 +133,7 @@ exports.others = function (req, res) { var now = new Date(); console.log('Adding song as played in ' + now.toJSON() + '...'); - var stmt = db.run('INSERT INTO songs (id, title, artist, done_in) VALUES (NULL, ?, ?, ?)', [ + db.run('INSERT INTO songs (id, title, artist, done_in) VALUES (NULL, ?, ?, ?)', [ posted_song, artist, now.toJSON() @@ -158,7 +158,7 @@ exports.others = function (req, res) { ); } - var stmt = db.run('INSERT INTO artists (id, name) VALUES (NULL, ?)', [ + db.run('INSERT INTO artists (id, name) VALUES (NULL, ?)', [ posted_artist ], function (error) { @@ -180,3 +180,19 @@ exports.others = function (req, res) { } ); }; + +/********************************************************************** + * Mark a song as played + *********************************************************************/ + +exports.played = function (req, res) { + var now = new Date(); + db.run('UPDATE songs SET done_in = ? WHERE id = ?', [ + now.toJSON(), req.body.id + ], function (error) { + if (error) { + throw error; + } + } + ); +} diff --git a/lyricsnode/views/index.html b/lyricsnode/views/index.html index 0167686..d662d94 100644 --- a/lyricsnode/views/index.html +++ b/lyricsnode/views/index.html @@ -78,7 +78,7 @@
- + Skip