fix: worldState growing with every request (#760)

This commit is contained in:
Sainan 2025-01-10 06:23:25 +01:00 committed by GitHub
parent 1c654650d4
commit eafdd9f755
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 35 additions and 14 deletions

View File

@ -5,51 +5,48 @@ import { IMongoDate, IOid } from "@/src/types/commonTypes";
export const worldStateController: RequestHandler = (req, res) => { export const worldStateController: RequestHandler = (req, res) => {
const worldState: IWorldState = { const worldState: IWorldState = {
...staticWorldState,
BuildLabel: BuildLabel:
typeof req.query.buildLabel == "string" typeof req.query.buildLabel == "string"
? req.query.buildLabel.split(" ").join("+") ? req.query.buildLabel.split(" ").join("+")
: buildConfig.buildLabel, : buildConfig.buildLabel,
Time: Math.round(Date.now() / 1000) Time: Math.round(Date.now() / 1000),
EndlessXpChoices: [],
...staticWorldState
}; };
const week = Math.trunc(new Date().getTime() / 604800000); const week = Math.trunc(new Date().getTime() / 604800000);
// Elite Sanctuary Onslaught cycling every week // Elite Sanctuary Onslaught cycling every week
worldState.NodeOverrides.push({ worldState.NodeOverrides.find(x => x.Node == "SolNode802")!.Seed = week; // unfaithful
_id: { $oid: "5ad9f9bb6df82a56eabf3d44" },
Node: "SolNode802",
Seed: week // unfaithful
});
// Holdfast, Cavia, & Hex bounties cycling every 2.5 hours; unfaithful implementation // Holdfast, Cavia, & Hex bounties cycling every 2.5 hours; unfaithful implementation
const bountyCycle = Math.trunc(new Date().getTime() / 9000000); const bountyCycle = Math.trunc(new Date().getTime() / 9000000);
const bountyCycleStart = bountyCycle * 9000000; const bountyCycleStart = bountyCycle * 9000000;
const bountyCycleEnd = bountyCycleStart + 9000000; const bountyCycleEnd = bountyCycleStart + 9000000;
worldState.SyndicateMissions.push({ worldState.SyndicateMissions[worldState.SyndicateMissions.findIndex(x => x.Tag == "ZarimanSyndicate")] = {
_id: { $oid: bountyCycleStart.toString(16) + "0000000000000029" }, _id: { $oid: bountyCycleStart.toString(16) + "0000000000000029" },
Activation: { $date: { $numberLong: bountyCycleStart.toString() } }, Activation: { $date: { $numberLong: bountyCycleStart.toString() } },
Expiry: { $date: { $numberLong: bountyCycleEnd.toString() } }, Expiry: { $date: { $numberLong: bountyCycleEnd.toString() } },
Tag: "ZarimanSyndicate", Tag: "ZarimanSyndicate",
Seed: bountyCycle, Seed: bountyCycle,
Nodes: [] Nodes: []
}); };
worldState.SyndicateMissions.push({ worldState.SyndicateMissions[worldState.SyndicateMissions.findIndex(x => x.Tag == "EntratiLabSyndicate")] = {
_id: { $oid: bountyCycleStart.toString(16) + "0000000000000004" }, _id: { $oid: bountyCycleStart.toString(16) + "0000000000000004" },
Activation: { $date: { $numberLong: bountyCycleStart.toString() } }, Activation: { $date: { $numberLong: bountyCycleStart.toString() } },
Expiry: { $date: { $numberLong: bountyCycleEnd.toString() } }, Expiry: { $date: { $numberLong: bountyCycleEnd.toString() } },
Tag: "EntratiLabSyndicate", Tag: "EntratiLabSyndicate",
Seed: bountyCycle, Seed: bountyCycle,
Nodes: [] Nodes: []
}); };
worldState.SyndicateMissions.push({ worldState.SyndicateMissions[worldState.SyndicateMissions.findIndex(x => x.Tag == "HexSyndicate")] = {
_id: { $oid: bountyCycleStart.toString(16) + "0000000000000006" }, _id: { $oid: bountyCycleStart.toString(16) + "0000000000000006" },
Activation: { $date: { $numberLong: bountyCycleStart.toString(10) } }, Activation: { $date: { $numberLong: bountyCycleStart.toString(10) } },
Expiry: { $date: { $numberLong: bountyCycleEnd.toString(10) } }, Expiry: { $date: { $numberLong: bountyCycleEnd.toString(10) } },
Tag: "HexSyndicate", Tag: "HexSyndicate",
Seed: bountyCycle, Seed: bountyCycle,
Nodes: [] Nodes: []
}); };
// Circuit choices cycling every week // Circuit choices cycling every week
worldState.EndlessXpChoices.push({ worldState.EndlessXpChoices.push({

View File

@ -340,6 +340,14 @@
} }
] ]
}, },
{
"_id": { "$oid": "663a71c80000000000000004" },
"Activation": { "$date": { "$numberLong": "1715106248403" } },
"Expiry": { "$date": { "$numberLong": "2000000000000" } },
"Tag": "EntratiLabSyndicate",
"Seed": 99562,
"Nodes": []
},
{ {
"_id": { "$oid": "663a71c80000000000000008" }, "_id": { "$oid": "663a71c80000000000000008" },
"Activation": { "$date": { "$numberLong": "1715106248403" } }, "Activation": { "$date": { "$numberLong": "1715106248403" } },
@ -471,6 +479,22 @@
"xpAmounts": [780, 780, 780, 780, 1540] "xpAmounts": [780, 780, 780, 780, 1540]
} }
] ]
},
{
"_id": { "$oid": "663a71c80000000000000029" },
"Activation": { "$date": { "$numberLong": "1715106248403" } },
"Expiry": { "$date": { "$numberLong": "2000000000000" } },
"Tag": "ZarimanSyndicate",
"Seed": 99562,
"Nodes": []
},
{
"_id": { "$oid": "676b8d340000000000000006" },
"Activation": { "$date": { "$numberLong": "1735101748215" } },
"Expiry": { "$date": { "$numberLong": "2000000000000" } },
"Tag": "HexSyndicate",
"Seed": 33872,
"Nodes": []
} }
], ],
"ActiveMissions": [ "ActiveMissions": [
@ -666,6 +690,7 @@
{ "_id": { "$oid": "549b18e9b029cef5991d6aec" }, "Node": "EuropaHUB", "Hide": true }, { "_id": { "$oid": "549b18e9b029cef5991d6aec" }, "Node": "EuropaHUB", "Hide": true },
{ "_id": { "$oid": "54a1737aeb658f6cbccf70ff" }, "Node": "ErisHUB", "Hide": true }, { "_id": { "$oid": "54a1737aeb658f6cbccf70ff" }, "Node": "ErisHUB", "Hide": true },
{ "_id": { "$oid": "54a736ddec12f80bd6e9e326" }, "Node": "VenusHUB", "Hide": true }, { "_id": { "$oid": "54a736ddec12f80bd6e9e326" }, "Node": "VenusHUB", "Hide": true },
{ "_id": { "$oid": "5ad9f9bb6df82a56eabf3d44" }, "Node": "SolNode802", "Seed": 9969639 },
{ {
"_id": { "$oid": "5b8817c2bd4f253264d6aa91" }, "_id": { "$oid": "5b8817c2bd4f253264d6aa91" },
"Node": "EarthHUB", "Node": "EarthHUB",
@ -1078,7 +1103,6 @@
"ConstructionProjects": [], "ConstructionProjects": [],
"TwitchPromos": [], "TwitchPromos": [],
"ExperimentRecommended": [], "ExperimentRecommended": [],
"EndlessXpChoices": [],
"ForceLogoutVersion": 0, "ForceLogoutVersion": 0,
"SeasonInfo": { "SeasonInfo": {
"Activation": { "$date": { "$numberLong": "1715796000000" } }, "Activation": { "$date": { "$numberLong": "1715796000000" } },