Correct count: only count every element once

This commit is contained in:
Pieter Vander Vennet 2023-10-05 15:20:02 +02:00
parent 535de1fb54
commit 16ab6ac69d

View file

@ -278,7 +278,8 @@ export class Postbuilder {
const report = this._config.report const report = this._config.report
const overpass = new Overpass(report) const overpass = new Overpass(report)
const data = await overpass.query() const data = await overpass.query()
const total = data.elements.length const ids = data.elements.map(e => e.type+"/"+e.id)
const total = new Set<string>(ids).size
const date = data.osm3s.timestamp_osm_base.substring(0, 10) const date = data.osm3s.timestamp_osm_base.substring(0, 10)
lastPostId = (await this._poster.writeMessage( lastPostId = (await this._poster.writeMessage(
report.post.replace(/{total}/g, "" + total).replace(/{date}/g, date), report.post.replace(/{total}/g, "" + total).replace(/{date}/g, date),