forked from OpenWF/SpaceNinjaServer
chore: optimise stats/view.php (#816)
This commit is contained in:
parent
5d4c454b0b
commit
d25a969269
@ -1,14 +1,14 @@
|
|||||||
import { RequestHandler } from "express";
|
import { RequestHandler } from "express";
|
||||||
import { getAccountIdForRequest } from "@/src/services/loginService";
|
import { getAccountIdForRequest } from "@/src/services/loginService";
|
||||||
import { Inventory } from "@/src/models/inventoryModels/inventoryModel";
|
|
||||||
import { IStatsView } from "@/src/types/statTypes";
|
import { IStatsView } from "@/src/types/statTypes";
|
||||||
import { config } from "@/src/services/configService";
|
import { config } from "@/src/services/configService";
|
||||||
import allScans from "@/static/fixed_responses/allScans.json";
|
import allScans from "@/static/fixed_responses/allScans.json";
|
||||||
import { ExportEnemies } from "warframe-public-export-plus";
|
import { ExportEnemies } from "warframe-public-export-plus";
|
||||||
|
import { getInventory } from "@/src/services/inventoryService";
|
||||||
|
|
||||||
const viewController: RequestHandler = async (req, res) => {
|
const viewController: RequestHandler = async (req, res) => {
|
||||||
const accountId = await getAccountIdForRequest(req);
|
const accountId = await getAccountIdForRequest(req);
|
||||||
const inventory = await Inventory.findOne({ accountOwnerId: accountId });
|
const inventory = await getInventory(accountId, "XPInfo");
|
||||||
if (!inventory) {
|
if (!inventory) {
|
||||||
res.status(400).json({ error: "inventory was undefined" });
|
res.status(400).json({ error: "inventory was undefined" });
|
||||||
return;
|
return;
|
||||||
@ -23,12 +23,16 @@ const viewController: RequestHandler = async (req, res) => {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (config.unlockAllScans) {
|
if (config.unlockAllScans) {
|
||||||
responseJson.Scans = allScans;
|
const scans = new Set(allScans);
|
||||||
for (const type of Object.keys(ExportEnemies.avatars)) {
|
for (const type of Object.keys(ExportEnemies.avatars)) {
|
||||||
if (!responseJson.Scans.find(x => x.type == type)) {
|
if (!scans.has(type)) {
|
||||||
responseJson.Scans.push({ type, scans: 9999 });
|
scans.add(type);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
responseJson.Scans = [];
|
||||||
|
for (const type of scans) {
|
||||||
|
responseJson.Scans.push({ type: type, scans: 9999 });
|
||||||
|
}
|
||||||
}
|
}
|
||||||
res.json(responseJson);
|
res.json(responseJson);
|
||||||
};
|
};
|
||||||
|
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user