From 7625f94a5cacf63d113da7e3de3e6d7320911a7c Mon Sep 17 00:00:00 2001 From: Antoine WEBER Date: Thu, 24 Sep 2015 18:15:40 +0200 Subject: [PATCH] regroupement des commandes sql --- routes/show.js | 33 ++++++++++++++++++--------------- views/show.jade | 8 ++------ 2 files changed, 20 insertions(+), 21 deletions(-) diff --git a/routes/show.js b/routes/show.js index 1b195a9..45708ce 100644 --- a/routes/show.js +++ b/routes/show.js @@ -32,11 +32,10 @@ router.get('/:id', function(req, res, next) { shows = row; }); - db.each("SELECT episode.id as id, episode.title as titre, episode.[index] as episode, season.[index] as saison "+ + db.each("SELECT episode.id as id, episode.title as titre, episode.[index] as episode, episode.duration as second, season.[index] as saison "+ "FROM metadata_items episode,metadata_items season,metadata_items show "+ "WHERE episode.parent_id=season.id AND season.parent_id = show.id AND show.id = ? ",req.params.id, function(err, row) { - console.log(err); - console.log(row); + /*//découpage des hints var params = {}; var tab = row.hints.split('&'); @@ -45,29 +44,33 @@ router.get('/:id', function(req, res, next) { params[tab2[0]] = decodeURIComponent(tab2[1]); }); row.info_meta = params; + */ - if(typeof row.info_meta !== 'undefined' && typeof row.info_meta.season !== 'undefined' && typeof row.info_meta.episode !== 'undefined'){ - row.season_episode = "S"+addZero(row.info_meta.season)+"E"+addZero(row.info_meta.episode); + if(typeof row.episode !== '' && row.saison !== '' ){ + row.season_episode = "S"+addZero(row.saison)+"E"+addZero(row.episode ); } - row.duree = formatDuree(row.second);*/ + row.duree = formatDuree(row.second); data.push(row); }, - //aprés toute les opération de la base + function() { + //a la fin du foreach + }); + + + },function(){ + //aprés toute les opération de la base var titre = "Série inexistante"; if(show != null){ title = 'Episode de '+show.title; } - res.render('show',{ - title: titre, - show: show, - videos: data - }); - }); - - + res.render('show',{ + title: titre, + show: show, + videos: data + }); }); db.close(); diff --git a/views/show.jade b/views/show.jade index e450e94..47b1e7e 100644 --- a/views/show.jade +++ b/views/show.jade @@ -7,19 +7,15 @@ block content thead tr th Nom - th Saison - th Episode + th Saison & Episode th Durée - th Année tbody each video, i in videos tr td a(href="/movie/#{video.id}")= video.titre - td= video.saison - td= video.episode + td= video.season_episode td= video.duree - td= video.year script. $(document).ready(function() { $('#example').DataTable({