Trying to improve frontpage fetching

This commit is contained in:
Kasper Rynning-Tønnesen
2017-09-17 11:33:01 +02:00
parent 5bbde84a7c
commit 850be93973
9 changed files with 28 additions and 59 deletions

View File

@@ -3,19 +3,23 @@ var frontpage_lists = function(msg, socket) {
socket.emit("update_required");
}
db.collection("frontpage_lists").find({frontpage:true, count: {$gt: 0}}, function(err, docs){
db.collection("connected_users").find({"_id": "total_users"}, function(err, tot){
socket.emit("playlists", {channels: docs, viewers: tot[0].total_users});
});
console.log("gotten second ", Functions.get_time());
db.collection("frontpage_lists").find({frontpage:true, count: {$ne: 0}}, function(err, docs){
console.log("gotten third ", Functions.get_time());
db.collection("connected_users").find({"_id": "total_users"}, function(err, tot){
console.log("sending frontpage ", Functions.get_time());
socket.compress(true).emit("playlists", {channels: docs, viewers: tot[0].total_users});
console.log("sent frontpage ", Functions.get_time());
});
});
}
function update_frontpage(coll, id, title) {
db.collection("frontpage_lists").update({_id: coll}, {$set: {
id: id,
title: title,
accessed: Functions.get_time()}
},{upsert: true}, function(err, returnDocs){});
db.collection("frontpage_lists").update({_id: coll}, {$set: {
id: id,
title: title,
accessed: Functions.get_time()}
},{upsert: true}, function(err, returnDocs){});
}
module.exports.update_frontpage = update_frontpage;