mirror of
https://github.com/KevinMidboe/zoff.git
synced 2025-10-29 18:00:23 +00:00
Removed unnecessary query
This commit is contained in:
@@ -103,10 +103,10 @@ io.on('connection', function(socket){
|
|||||||
|
|
||||||
socket.on('end', function(id)
|
socket.on('end', function(id)
|
||||||
{
|
{
|
||||||
db.collection(coll).find({now_playing:true}, function(err, docs){
|
db.collection(coll).find({now_playing:true}, function(err, np){
|
||||||
//console.log(docs);
|
//console.log(docs);
|
||||||
//console.log(docs.length);
|
//console.log(docs.length);
|
||||||
if(docs.length == 1 && docs[0]["id"] == id){
|
if(np.length == 1 && np[0]["id"] == id){
|
||||||
db.collection(coll).find({views:{$exists:true}}, function(err, docs){
|
db.collection(coll).find({views:{$exists:true}}, function(err, docs){
|
||||||
var startTime = docs[0]["startTime"];
|
var startTime = docs[0]["startTime"];
|
||||||
if(docs[0]["removeplay"] == true)
|
if(docs[0]["removeplay"] == true)
|
||||||
@@ -117,44 +117,43 @@ io.on('connection', function(socket){
|
|||||||
})
|
})
|
||||||
}else
|
}else
|
||||||
{
|
{
|
||||||
db.collection(coll).find({id:id}, function(err, docs){
|
|
||||||
if(startTime+docs[0]["duration"]<=get_time()-1)
|
if(startTime+np[0]["duration"]<=get_time()-1)
|
||||||
{
|
{
|
||||||
db.collection(coll).update({now_playing:true, id:id},
|
db.collection(coll).update({now_playing:true, id:id},
|
||||||
{$set:{
|
{$set:{
|
||||||
now_playing:false,
|
now_playing:false,
|
||||||
votes:0,
|
votes:0,
|
||||||
guids:[]
|
guids:[]
|
||||||
}}, function(err, docs)
|
}}, function(err, docs)
|
||||||
|
{
|
||||||
|
//console.log(err);
|
||||||
|
//console.log(docs["n"]);
|
||||||
|
if(docs["n"] == 1)
|
||||||
{
|
{
|
||||||
//console.log(err);
|
db.collection(coll).aggregate([
|
||||||
//console.log(docs["n"]);
|
{$match:{now_playing:false}},
|
||||||
if(docs["n"] == 1)
|
{$sort:{votes:-1, added:1}},
|
||||||
{
|
{$limit:1}], function(err, docs){
|
||||||
db.collection(coll).aggregate([
|
if(docs.length > 0){
|
||||||
{$match:{now_playing:false}},
|
db.collection(coll).update({id:docs[0]["id"]},
|
||||||
{$sort:{votes:-1, added:1}},
|
{$set:{
|
||||||
{$limit:1}], function(err, docs){
|
now_playing:true,
|
||||||
if(docs.length > 0){
|
votes:0,
|
||||||
db.collection(coll).update({id:docs[0]["id"]},
|
guids:[],
|
||||||
{$set:{
|
added:get_time()}}, function(err, docs){
|
||||||
now_playing:true,
|
db.collection(coll).update({views:{$exists:true}},
|
||||||
votes:0,
|
{$set:{startTime:get_time(), skips:[]}}, function(err, docs){
|
||||||
guids:[],
|
sort_list(coll, undefined, true, true);
|
||||||
added:get_time()}}, function(err, docs){
|
|
||||||
db.collection(coll).update({views:{$exists:true}},
|
|
||||||
{$set:{startTime:get_time(), skips:[]}}, function(err, docs){
|
|
||||||
sort_list(coll, undefined, true, true);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
}
|
});
|
||||||
});
|
}
|
||||||
}
|
});
|
||||||
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user