Skip to content

Commit 76c5a6f

Browse files
committed
Fix storage count issue
1 parent 4874e7f commit 76c5a6f

4 files changed

Lines changed: 4 additions & 9 deletions

File tree

OpenFlow/src/Messages/Message.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4282,13 +4282,12 @@ export class Message {
42824282
if (usercount.length > 0) {
42834283
Logger.instanse.debug("[housekeeping] Begin updating all users (" + usercount[0].userCount + ") dbusage field");
42844284
}
4285-
42864285
const cursor = Config.db.db.collection("users").find({ "_type": "user", lastseen: { "$gte": yesterday } })
42874286
for await (const u of cursor) {
42884287
if (u.dbusage == null) u.dbusage = 0;
42894288
index++;
42904289
const pipe = [
4291-
{ "$match": { "userid": u._id, timestamp: { "$gte": yesterday } } },
4290+
{ "$match": { "userid": u._id, timestamp: timestamp } },
42924291
{
42934292
"$group":
42944293
{
@@ -4300,8 +4299,6 @@ export class Message {
43004299
}
43014300
]// "items": { "$push": "$$ROOT" }
43024301
const items: any[] = await Config.db.db.collection("dbusage").aggregate(pipe).toArray();
4303-
4304-
43054302
if (items.length > 0) {
43064303
Logger.instanse.debug("[housekeeping][" + index + "/" + usercount[0].userCount + "] " + u.name + " " + this.formatBytes(items[0].size) + " from " + items[0].count + " collections");
43074304
await Config.db.db.collection("users").updateOne({ _id: u._id }, { $set: { "dbusage": items[0].size } });
@@ -4316,7 +4313,6 @@ export class Message {
43164313
}
43174314
if (Config.multi_tenant) {
43184315
try {
4319-
let index = 0;
43204316
const usercount = await Config.db.db.collection("users").aggregate([{ "$match": { "_type": "customer" } }, { $count: "userCount" }]).toArray();
43214317
if (usercount.length > 0) {
43224318
Logger.instanse.debug("[housekeeping] Begin updating all customers (" + usercount[0].userCount + ") dbusage field");
@@ -4369,7 +4365,6 @@ export class Message {
43694365
for (let u of c.users) dbusage += (u.dbusage ? u.dbusage : 0);
43704366
await Config.db.db.collection("users").updateOne({ _id: c._id }, { $set: { "dbusage": dbusage } });
43714367
Logger.instanse.debug("[housekeeping] " + c.name + " using " + this.formatBytes(dbusage));
4372-
index++;
43734368
}
43744369
var sleep = (ms) => {
43754370
return new Promise(resolve => {

OpenFlowNodeRED/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@openiap/nodered",
3-
"version": "1.3.81",
3+
"version": "1.3.82",
44
"description": "Simple wrapper around NodeRed, RabbitMQ and MongoDB to support a more scaleable NodeRed implementation.\r Also the \"backend\" for [OpenRPA](https://github.com/skadefro/OpenRPA)",
55
"main": "index.js",
66
"scripts": {

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.3.81
1+
1.3.82

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@openiap/openflow",
3-
"version": "1.3.81",
3+
"version": "1.3.82",
44
"description": "Simple wrapper around NodeRed, RabbitMQ and MongoDB to support a more scaleable NodeRed implementation.\r Also the \"backend\" for [OpenRPA](https://github.com/skadefro/OpenRPA)",
55
"main": "index.js",
66
"scripts": {

0 commit comments

Comments
 (0)