From 4d5384aa43cdfb147b9bcafddc16343749bd4fd7 Mon Sep 17 00:00:00 2001 From: Julien Dessaux Date: Wed, 7 Jun 2023 00:22:52 +0200 Subject: Use waypoints function where relevant --- lib/systems.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'lib/systems.js') diff --git a/lib/systems.js b/lib/systems.js index fcbf41a..e03da6c 100644 --- a/lib/systems.js +++ b/lib/systems.js @@ -29,20 +29,21 @@ export async function system(ctx) { // Retrieves a list of waypoints that have a specific ctx.trait like a SHIPYARD or a MARKETPLACE in the system ctx.symbol export async function trait(ctx) { - const s = await system(ctx); - return s.waypoints.filter(s => s.traits.some(t => t.symbol === ctx.trait)); + const w = await waypoints(ctx); + return w.filter(s => s.traits.some(t => t.symbol === ctx.trait)); } // Retrieves a list of waypoints that have a specific ctx.type like ASTEROID_FIELD in the system ctx.symbol export async function type(ctx, response) { - const s = await system(ctx); - return s.waypoints.filter(s => s.type === ctx.type); + const w = await waypoints(ctx); + return w.filter(s => s.type === ctx.type); } // Retrieves the system's information for ctx.symbol and caches it in the database export async function waypoints(ctx) { await system(ctx); let updated = db.getSystemUpdated(ctx.symbol); + // TODO handle uncharted systems if (updated === null) { let waypoints = []; for (let page=1; true; ++page) { -- cgit v1.2.3