reduire les doublons

This commit is contained in:
WEBER Antoine
2015-09-24 00:17:03 +02:00
parent 00952c81d7
commit 6cc56aef44
4 changed files with 24 additions and 23 deletions

View File

@@ -54,9 +54,9 @@ router.get('/:id', function(req, res, next) {
channel_info = row;
});
db.each("SELECT i.id as id, i.title as title, t.hints as hints, i.duration as second, t.size as size, i.year as year"
+ " FROM media_items t, metadata_items i "
+ " WHERE t.metadata_item_id = i.id AND i.title != '' AND t.library_section_id = ? "
db.each("SELECT i.id as id, i.title as title, i.duration as second, i.year as year"
+ " FROM metadata_items i, media_items t "
+ " WHERE i.id = t.metadata_item_id AND i.title != '' AND t.library_section_id = ? "
+ " ORDER BY i.title ASC",req.params.id, function(err, row) {
//découpage des hints

View File

@@ -1,6 +1,22 @@
var express = require('express');
var router = express.Router();
function humanFileSize(bytes, si) {
var thresh = si ? 1000 : 1024;
if(Math.abs(bytes) < thresh) {
return bytes + ' B';
}
var units = si
? ['kB','MB','GB','TB','PB','EB','ZB','YB']
: ['KiB','MiB','GiB','TiB','PiB','EiB','ZiB','YiB'];
var u = -1;
do {
bytes /= thresh;
++u;
} while(Math.abs(bytes) >= thresh && u < units.length - 1);
return bytes.toFixed(1)+' '+units[u];
}
/* GET home page. */
router.get('/:id', function(req, res, next) {
@@ -22,6 +38,8 @@ router.get('/:id', function(req, res, next) {
var filename = tab2[tab2.length -1];
ligne.filename = filename;
ligne.size = humanFileSize(ligne.size,true);
row.file.push(ligne);
},function(){
res.render('movie', { title: 'Détail vidéo',movie: row });