Skip to content

Commit

Permalink
from overpass
Browse files Browse the repository at this point in the history
  • Loading branch information
zbycz committed Nov 26, 2024
1 parent 01f3274 commit 208d6ac
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions src/server/climbing-tiles/refresh.ts
Original file line number Diff line number Diff line change
Expand Up @@ -200,15 +200,13 @@ export const refresh = async (log: (line: string) => void) => {
await client.connect();

const start = performance.now();
log('Deleting old records...');
await client.query('DELETE FROM climbing_tiles');

log('Fetching data from Overpass...');
// const data = await fetchFromOverpass();
const data = await fetchFromOverpass();
// fs.writeFileSync('../overpass.json', JSON.stringify(data));
const data = JSON.parse(
fs.readFileSync('../overpass.json').toString(),
) as OsmResponse;
// const data = JSON.parse(
// fs.readFileSync('../overpass.json').toString(),
// ) as OsmResponse;
log(`Overpass elements: ${data.elements.length}`);

const records = getNewRecords(data); // ~ 16k records
Expand All @@ -217,7 +215,7 @@ export const refresh = async (log: (line: string) => void) => {
const columns = Object.keys(records[0]);
const values = records.map((record) => Object.values(record));
const query = format(
`INSERT INTO climbing_tiles(%I) VALUES %L`,
`DELETE FROM climbing_tiles;INSERT INTO climbing_tiles(%I) VALUES %L`,
columns,
values,
);
Expand Down

0 comments on commit 208d6ac

Please sign in to comment.