Browse Source

Fixed users count on community stations not showing up.

KrisVos130 8 years ago
parent
commit
f2f7e607f6
1 changed files with 19 additions and 4 deletions
  1. 19 4
      app/server/server.js

+ 19 - 4
app/server/server.js

@@ -102,18 +102,33 @@ function checkUsersPR() {
         //var usubs = connection._meteorSession._universalSubs;
     });
     var emptyStations = [];
+    var emptyCommunityStations = [];
     stations.forEach(function (station) {
         emptyStations.push(station);
     });
+    communityStations.forEach(function (station) {
+        emptyCommunityStations.push(station);
+    });
     for (var key in output) {
-        getStation(key, function (station) {
-            emptyStations.splice(emptyStations.indexOf(station), 1);
-            Rooms.update({type: key}, {$set: {users: output[key]}});
-        });
+        if (key.startsWith("pr_")) {
+            var tempKey = key.substring(3);
+            getCommunityStation(tempKey, function (station) {
+                emptyCommunityStations.splice(emptyCommunityStations.indexOf(station), 1);
+                CommunityStations.update({name: tempKey}, {$set: {users: output[key]}});
+            });
+        } else {
+            getStation(key, function (station) {
+                emptyStations.splice(emptyStations.indexOf(station), 1);
+                Rooms.update({type: key}, {$set: {users: output[key]}});
+            });
+        }
     }
     emptyStations.forEach(function (emptyStation) {
         Rooms.update({type: emptyStation.type}, {$set: {users: 0}});
     });
+    emptyCommunityStations.forEach(function (emptyStation) {
+        CommunityStations.update({name: emptyStation.name}, {$set: {users: 0}});
+    });
     return output;
 }