From ee6e430ef4a82970110099c5690bf905bf2d2122 Mon Sep 17 00:00:00 2001 From: Pieter Vander Vennet Date: Sun, 18 Feb 2024 17:38:29 +0100 Subject: [PATCH] Debugging --- scripts/osm2pgsql/tilecountServer.ts | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/scripts/osm2pgsql/tilecountServer.ts b/scripts/osm2pgsql/tilecountServer.ts index 123e06831..594ca634f 100644 --- a/scripts/osm2pgsql/tilecountServer.ts +++ b/scripts/osm2pgsql/tilecountServer.ts @@ -29,6 +29,7 @@ class OsmPoiDatabase { private readonly _client: Client private isConnected = false private supportedLayers: Set = undefined + private supportedLayersDate: Date = undefined private metaCache: PoiDatabaseMeta = undefined private metaCacheDate: Date = undefined @@ -65,16 +66,21 @@ class OsmPoiDatabase { } async getLayers(): Promise> { - if (this.supportedLayers !== undefined) { + if ( + this.supportedLayers !== undefined && + new Date().getTime() - this.supportedLayersDate.getTime() < 1000 * 60 * 60 * 24 + ) { return this.supportedLayers } - const result = await this._client.query( + const q = "SELECT table_name \n" + - "FROM information_schema.tables \n" + - "WHERE table_schema = 'public' AND table_name LIKE 'lines_%';" - ) + "FROM information_schema.tables \n" + + "WHERE table_schema = 'public' AND table_name LIKE 'lines_%';" + const result = await this._client.query(q) + console.log("Getting layers: ", q, result) const layers = result.rows.map((r) => r.table_name.substring("lines_".length)) this.supportedLayers = new Set(layers) + this.supportedLayersDate = new Date() return this.supportedLayers }