diff options
-rw-r--r-- | lib/systems.js | 9 |
1 files changed, 5 insertions, 4 deletions
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) { |