forked from MapComplete/MapComplete
Chore: linting
This commit is contained in:
parent
f5d7686c98
commit
c48827906e
4 changed files with 6 additions and 10 deletions
|
@ -3,7 +3,9 @@ import { OsmPoiDatabase } from "./osmPoiDatabase"
|
||||||
|
|
||||||
class CreateNewDatabase extends Script {
|
class CreateNewDatabase extends Script {
|
||||||
constructor() {
|
constructor() {
|
||||||
super("Creates a new version of the database. Usage: `createNewDatabase -- YYYY-MM-DD` which will create database `osm-poi.YYYY-MM-DD`")
|
super(
|
||||||
|
"Creates a new version of the database. Usage: `createNewDatabase -- YYYY-MM-DD` which will create database `osm-poi.YYYY-MM-DD`"
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
async main(args: string[]): Promise<void> {
|
async main(args: string[]): Promise<void> {
|
||||||
|
@ -12,5 +14,4 @@ class CreateNewDatabase extends Script {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
new CreateNewDatabase().run()
|
new CreateNewDatabase().run()
|
||||||
|
|
|
@ -12,5 +12,4 @@ class DeleteOldDbs extends Script {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
new DeleteOldDbs().run()
|
new DeleteOldDbs().run()
|
||||||
|
|
|
@ -68,7 +68,6 @@ export class OsmPoiDatabase {
|
||||||
const metaclient = this.getMetaClient()
|
const metaclient = this.getMetaClient()
|
||||||
await metaclient.connect()
|
await metaclient.connect()
|
||||||
try {
|
try {
|
||||||
|
|
||||||
const meta = await metaclient.query("SELECT datname FROM pg_database")
|
const meta = await metaclient.query("SELECT datname FROM pg_database")
|
||||||
let latest: string = undefined
|
let latest: string = undefined
|
||||||
let latestDate: Date = new Date(0)
|
let latestDate: Date = new Date(0)
|
||||||
|
@ -104,7 +103,7 @@ export class OsmPoiDatabase {
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log("Latest database is:", latest)
|
console.log("Latest database is:", latest)
|
||||||
return "osm-poi."+latest
|
return "osm-poi." + latest
|
||||||
}
|
}
|
||||||
|
|
||||||
async createNew(date: string) {
|
async createNew(date: string) {
|
||||||
|
@ -113,7 +112,6 @@ export class OsmPoiDatabase {
|
||||||
const metaclient = this.getMetaClient()
|
const metaclient = this.getMetaClient()
|
||||||
await metaclient.connect()
|
await metaclient.connect()
|
||||||
try {
|
try {
|
||||||
|
|
||||||
await metaclient.query(`CREATE DATABASE "${dbname}"`)
|
await metaclient.query(`CREATE DATABASE "${dbname}"`)
|
||||||
console.log("Database created - installing extensions")
|
console.log("Database created - installing extensions")
|
||||||
const client = new Client(this._connectionString + "/" + dbname)
|
const client = new Client(this._connectionString + "/" + dbname)
|
||||||
|
@ -129,7 +127,7 @@ export class OsmPoiDatabase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async deleteAllButLatest(){
|
async deleteAllButLatest() {
|
||||||
const dbs = await this.findSuitableDatabases()
|
const dbs = await this.findSuitableDatabases()
|
||||||
for (let i = 0; i < dbs.length - 1; i++) {
|
for (let i = 0; i < dbs.length - 1; i++) {
|
||||||
await this.deleteDatabase(dbs[i])
|
await this.deleteDatabase(dbs[i])
|
||||||
|
@ -152,7 +150,6 @@ export class OsmPoiDatabase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
async connectToLatest() {
|
async connectToLatest() {
|
||||||
const latest = await this.searchLatest()
|
const latest = await this.searchLatest()
|
||||||
this._client = new Client(this._connectionString + "/" + latest)
|
this._client = new Client(this._connectionString + "/" + latest)
|
||||||
|
@ -161,7 +158,7 @@ export class OsmPoiDatabase {
|
||||||
|
|
||||||
async getCount(
|
async getCount(
|
||||||
layer: string,
|
layer: string,
|
||||||
bbox: [[number, number], [number, number]] = undefined,
|
bbox: [[number, number], [number, number]] = undefined
|
||||||
): Promise<{ count: number; lat: number; lon: number }> {
|
): Promise<{ count: number; lat: number; lon: number }> {
|
||||||
await this.connectIfNeeded()
|
await this.connectIfNeeded()
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,6 @@ import { Server } from "../server"
|
||||||
import Script from "../Script"
|
import Script from "../Script"
|
||||||
import { OsmPoiDatabase } from "./osmPoiDatabase"
|
import { OsmPoiDatabase } from "./osmPoiDatabase"
|
||||||
|
|
||||||
|
|
||||||
class CachedSqlCount {
|
class CachedSqlCount {
|
||||||
private readonly _cache: Record<
|
private readonly _cache: Record<
|
||||||
string,
|
string,
|
||||||
|
|
Loading…
Reference in a new issue