Sorting on sending list via socket and RESTApi when projecting

This commit is contained in:
Kasper Rynning-Tønnesen
2018-05-30 11:39:20 +02:00
parent fcaa50cfd4
commit 68c24b6317
3 changed files with 7 additions and 33 deletions

View File

@@ -424,7 +424,8 @@ function send_list(coll, socket, send, list_send, configs, shuffled)
},
{
"$project": project_object
}
},
{ "$sort" : { "now_playing" : -1, "votes": -1, "added": 1 } }
], function(err, docs)
//db.collection(coll).find({type: {$ne: "suggested"}}, function(err, docs)
{

View File

@@ -178,7 +178,7 @@ var List = {
full_playlist[x].votes = 0;
}
}
List.sortList();
//List.sortList();
Helper.setHtml("#wrapper", "");

View File

@@ -812,33 +812,6 @@ router.route('/api/list/:channel_name').get(function(req, res) {
res.header("Access-Control-Allow-Origin", "*");
res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");
res.header({"Content-Type": "application/json"});
/*
var project_object = {
"id": 1,
"added": 1,
"guids": { "$literal": [] },
"now_playing": 1,
"title": 1,
"votes": { "$literal": 0 },
"start": 1,
"duration": 1,
"end": 1,
"type": 1,
"source": 1,
"thumbnail": 1
};
db.collection(new_channel).aggregate([
{
"$match": { type: "video" }
},
{
"$project": project_object
}
]
*/
var project_object = {
"_id": 0,
"id": 1,
@@ -864,7 +837,8 @@ db.collection(new_channel).aggregate([
},
{
"$project": project_object
}
},
{ "$sort" : { "now_playing" : -1, "votes": -1, "added": 1 } }
], function(err, docs) {
//db.collection(channel_name).find({views: {$exists: false}}, toShowChannel, function(err, docs) {
if(docs.length > 0) {
@@ -1160,9 +1134,8 @@ router.route('/api/list/:channel_name').post(function(req, res) {
{
"$match": { }
},
{
"$project": project_object
}
{ "$project": project_object },
{ "$sort" : { "now_playing" : -1, "votes": -1, "added": 1 } }
], function(err, list) {
//db.collection(channel_name).find({views: {$exists: false}}, toShowChannel, function(err, list) {
if(list.length > 0) {