forked from Juerd/shalog
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rented-overview.js
33 lines (28 loc) · 926 Bytes
/
rented-overview.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
"use strict";
const chalk = require("chalk");
const fs = require("fs");
const path = require("path");
let files = fs.readdirSync(path.join(__dirname, "db"));
const containers = {};
const locations = {};
files.filter((a) => a.endsWith("json")).forEach((id) => {
let file = require(path.join(__dirname, "db", id));
if (file.class == "Thing") {
if (file.location != undefined && file.location != "lhq-returns") {
if (locations[file.location] == undefined) {
locations[file.location] = new Set();
}
locations[file.location].add(file.id);
}
} else if (file.class == "Container") {
containers[id] = true;
}
});
Object.entries(locations).forEach(([loc, items]) => {
if (!containers[loc]) {
console.log("\n", chalk.red(loc, "has"));
items.forEach((item) => {
console.log(" ", item);
});
}
})