fix formatting
This commit is contained in:
parent
b12d84d4be
commit
2cd23324e5
8
db.js
8
db.js
@ -11,18 +11,18 @@ catch {
|
|||||||
save();
|
save();
|
||||||
}
|
}
|
||||||
|
|
||||||
function load () {
|
function load() {
|
||||||
db = JSON.parse(readFileSync(filename));
|
db = JSON.parse(readFileSync(filename));
|
||||||
}
|
}
|
||||||
|
|
||||||
function save () {
|
function save() {
|
||||||
writeFileSync(filename, JSON.stringify(db));
|
writeFileSync(filename, JSON.stringify(db));
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getResourceConfig () {
|
export function getResourceConfig() {
|
||||||
return db.resources;
|
return db.resources;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getUserConfig (username) {
|
export function getUserConfig(username) {
|
||||||
return db.users[username];
|
return db.users[username];
|
||||||
}
|
}
|
6
utils.js
6
utils.js
@ -1,7 +1,7 @@
|
|||||||
import { getUsedResources } from "./pve.js";
|
import { getUsedResources } from "./pve.js";
|
||||||
import { getUserConfig, getResourceConfig } from "./db.js";
|
import { getUserConfig, getResourceConfig } from "./db.js";
|
||||||
|
|
||||||
export async function getAllocatedResources (req, username) {
|
export async function getAllocatedResources(req, username) {
|
||||||
let dbResources = getResourceConfig();
|
let dbResources = getResourceConfig();
|
||||||
let used = await getUsedResources(req, dbResources);
|
let used = await getUsedResources(req, dbResources);
|
||||||
let max = getUserConfig(username).resources.max;
|
let max = getUserConfig(username).resources.max;
|
||||||
@ -9,10 +9,10 @@ export async function getAllocatedResources (req, username) {
|
|||||||
Object.keys(max).forEach((k) => {
|
Object.keys(max).forEach((k) => {
|
||||||
avail[k] = max[k] - used[k];
|
avail[k] = max[k] - used[k];
|
||||||
});
|
});
|
||||||
return {used: used, max: max, avail: avail, units: dbResources};
|
return { used: used, max: max, avail: avail, units: dbResources };
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function approveResources (req, username, request) {
|
export async function approveResources(req, username, request) {
|
||||||
|
|
||||||
let avail = (await getAllocatedResources(req, username)).avail;
|
let avail = (await getAllocatedResources(req, username)).avail;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user