|
|
@@ -116,17 +116,28 @@ export class Database {
|
|
|
|
|
|
await this.beginTransaction();
|
|
|
try {
|
|
|
- let c = 1;
|
|
|
for (const entry of data) {
|
|
|
const result = await this.run('INSERT INTO ServerDataEntry(ServerID, Timestamp) VALUES(?, ?);', [serverID, entry.time.getTime()]);
|
|
|
let entryID = result.lastID;
|
|
|
|
|
|
- for (const type of Object.keys(entry).filter(t => t !== 'time')) {
|
|
|
+ for (const type of Object.keys(entry).filter(t => !['time', 'hdd'].includes(t))) {
|
|
|
for (const key of Object.keys(entry[type])) {
|
|
|
await this.run('INSERT INTO ServerDataValue(EntryID, Type, Key, Value) VALUES(?, ?, ?, ?);', [entryID, type, key, entry[type][key]]);
|
|
|
}
|
|
|
}
|
|
|
- c++;
|
|
|
+
|
|
|
+ if (entry.hdd) {
|
|
|
+ for (const mount of Object.keys(entry.hdd)) {
|
|
|
+ for (const key of Object.keys(entry.hdd[mount])) {
|
|
|
+ await this.run('INSERT INTO ServerDataValue(EntryID, Type, Key, Value) VALUES(?, ?, ?, ?);', [
|
|
|
+ entryID,
|
|
|
+ `hdd:${mount}`,
|
|
|
+ key,
|
|
|
+ entry.hdd[mount][key]
|
|
|
+ ]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
await this.commit();
|
|
|
} catch (err) {
|
|
|
@@ -163,11 +174,16 @@ export class Database {
|
|
|
entry = res[res.length - 1];
|
|
|
}
|
|
|
|
|
|
- const type = line['Type'];
|
|
|
- if (typeof entry[type] === 'undefined') {
|
|
|
- entry[type] = {};
|
|
|
+ let type: string = line['Type'];
|
|
|
+ if (type.startsWith('hdd:')) {
|
|
|
+ const mount = type.substring(4);
|
|
|
+ if (typeof entry.hdd === 'undefined') entry.hdd = {};
|
|
|
+ if (typeof entry.hdd[mount] === 'undefined') entry.hdd[mount] = {} as ReducedValuesMinMax;
|
|
|
+ entry.hdd[mount][line['Key']] = line['Value'];
|
|
|
+ } else {
|
|
|
+ if (typeof entry[type] === 'undefined') entry[type] = {};
|
|
|
+ entry[type][line['Key']] = line['Value'];
|
|
|
}
|
|
|
- entry[type][line['Key']] = line['Value'];
|
|
|
|
|
|
return res;
|
|
|
}, [] as ReducedData[]);
|