mirror of
https://github.com/KevinMidboe/zoff.git
synced 2025-10-29 18:00:23 +00:00
Fixed issue with viewercounter being below 0
This commit is contained in:
@@ -124,7 +124,7 @@ module.exports = function() {
|
|||||||
}, function(err, updated) {
|
}, function(err, updated) {
|
||||||
if(updated.nModified > 0) {
|
if(updated.nModified > 0) {
|
||||||
io.to(coll).emit("viewers", updated.users);
|
io.to(coll).emit("viewers", updated.users);
|
||||||
db.collection("connected_users").update({"_id": "total_users"}, {$inc: {total_users: -1}}, function(err, docs){
|
db.collection("connected_users").update({"_id": "total_users", total_users: {$gt: 0}}, {$inc: {total_users: -1}}, function(err, docs){
|
||||||
db.collection("connected_users").update({"_id": "offline_users"}, {$addToSet: {users: guid}}, function(err, docs) {
|
db.collection("connected_users").update({"_id": "offline_users"}, {$addToSet: {users: guid}}, function(err, docs) {
|
||||||
if(docs.nModified == 1) {
|
if(docs.nModified == 1) {
|
||||||
db.collection("connected_users").update({"_id": "total_users"}, {$inc: {total_users: 1}}, function(err, docs) {});
|
db.collection("connected_users").update({"_id": "total_users"}, {$inc: {total_users: 1}}, function(err, docs) {});
|
||||||
|
|||||||
@@ -184,7 +184,7 @@ function change_song(coll, error, id) {
|
|||||||
if(now_playing_doc.length == 2) next_song = now_playing_doc[1].id;
|
if(now_playing_doc.length == 2) next_song = now_playing_doc[1].id;
|
||||||
List.change_song_post(coll, next_song);
|
List.change_song_post(coll, next_song);
|
||||||
io.to(coll).emit("channel", {type: "deleted", value: now_playing_doc[0].id, removed: true});
|
io.to(coll).emit("channel", {type: "deleted", value: now_playing_doc[0].id, removed: true});
|
||||||
db.collection("frontpage_lists").update({_id: coll}, {$inc: {count: -1}, $set:{accessed: Functions.get_time()}}, {upsert: true}, function(err, docs){});
|
db.collection("frontpage_lists").update({_id: coll, count: {$gt: 0}}, {$inc: {count: -1}, $set:{accessed: Functions.get_time()}}, {upsert: true}, function(err, docs){});
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
if((docs[0].skipped_time != undefined && docs[0].skipped_time != Functions.get_time()) || docs[0].skipped_time == undefined) {
|
if((docs[0].skipped_time != undefined && docs[0].skipped_time != Functions.get_time()) || docs[0].skipped_time == undefined) {
|
||||||
@@ -211,7 +211,7 @@ function change_song(coll, error, id) {
|
|||||||
if(now_playing_doc.length == 2) next_song = now_playing_doc[1].id;
|
if(now_playing_doc.length == 2) next_song = now_playing_doc[1].id;
|
||||||
List.change_song_post(coll, next_song);
|
List.change_song_post(coll, next_song);
|
||||||
io.to(coll).emit("channel", {type: "deleted", value: now_playing_doc[0].id, removed: true});
|
io.to(coll).emit("channel", {type: "deleted", value: now_playing_doc[0].id, removed: true});
|
||||||
db.collection("frontpage_lists").update({_id: coll}, {$inc: {count: -1}, $set:{accessed: Functions.get_time()}}, {upsert: true}, function(err, docs){});
|
db.collection("frontpage_lists").update({_id: coll, count: {$gt: 0}}, {$inc: {count: -1}, $set:{accessed: Functions.get_time()}}, {upsert: true}, function(err, docs){});
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
if((docs[0].skipped_time != undefined && docs[0].skipped_time != Functions.get_time()) || docs[0].skipped_time == undefined) {
|
if((docs[0].skipped_time != undefined && docs[0].skipped_time != Functions.get_time()) || docs[0].skipped_time == undefined) {
|
||||||
@@ -404,7 +404,7 @@ function end(obj, coll, guid, offline, socket) {
|
|||||||
{
|
{
|
||||||
db.collection(coll).remove({now_playing:true}, function(err, docs){
|
db.collection(coll).remove({now_playing:true}, function(err, docs){
|
||||||
List.change_song_post(coll);
|
List.change_song_post(coll);
|
||||||
db.collection("frontpage_lists").update({_id:coll}, {$inc:{count:-1}, $set:{accessed: Functions.get_time()}}, {upsert:true}, function(err, docs){});
|
db.collection("frontpage_lists").update({_id:coll, count: {$gt: 0}}, {$inc:{count:-1}, $set:{accessed: Functions.get_time()}}, {upsert:true}, function(err, docs){});
|
||||||
});
|
});
|
||||||
}else{
|
}else{
|
||||||
if(startTime+parseInt(np[0].duration)<=Functions.get_time()+5)
|
if(startTime+parseInt(np[0].duration)<=Functions.get_time()+5)
|
||||||
@@ -499,7 +499,7 @@ function left_channel(coll, guid, short_id, in_list, socket, change)
|
|||||||
io.to(coll).emit("viewers", new_doc[0].users.length);
|
io.to(coll).emit("viewers", new_doc[0].users.length);
|
||||||
socket.leave(coll);
|
socket.leave(coll);
|
||||||
});
|
});
|
||||||
db.collection("connected_users").update({"_id": "total_users"}, {$inc: {total_users: -1}}, function(err, updated){});
|
db.collection("connected_users").update({"_id": "total_users", total_users: {$gt: 0}}, {$inc: {total_users: -1}}, function(err, updated){});
|
||||||
|
|
||||||
if(!change) {
|
if(!change) {
|
||||||
Functions.remove_name_from_db(guid, name);
|
Functions.remove_name_from_db(guid, name);
|
||||||
|
|||||||
@@ -258,7 +258,7 @@ function del(params, socket, socketid) {
|
|||||||
db.collection(coll).remove({id:params.id}, function(err, docs){
|
db.collection(coll).remove({id:params.id}, function(err, docs){
|
||||||
socket.emit("toast", "deletesong");
|
socket.emit("toast", "deletesong");
|
||||||
io.to(coll).emit("channel", {type:"deleted", value: params.id});
|
io.to(coll).emit("channel", {type:"deleted", value: params.id});
|
||||||
if(dont_increment) db.collection("frontpage_lists").update({_id: coll}, {$inc: {count: -1}, $set:{accessed: Functions.get_time()}}, {upsert: true}, function(err, docs){});
|
if(dont_increment) db.collection("frontpage_lists").update({_id: coll, count: {$gt: 0}}, {$inc: {count: -1}, $set:{accessed: Functions.get_time()}}, {upsert: true}, function(err, docs){});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user