From f6cbb44454b8dd020208abfd331280172ef95746 Mon Sep 17 00:00:00 2001 From: pietervdvn Date: Mon, 10 May 2021 23:42:01 +0200 Subject: [PATCH] Add a contributor counting actor --- Logic/ContributorCount.ts | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 Logic/ContributorCount.ts diff --git a/Logic/ContributorCount.ts b/Logic/ContributorCount.ts new file mode 100644 index 000000000..9c954bdfb --- /dev/null +++ b/Logic/ContributorCount.ts @@ -0,0 +1,21 @@ +/// Given a feature source, calculates a list of OSM-contributors who mapped the latest versions +import FeatureSource from "./FeatureSource/FeatureSource"; +import {UIEventSource} from "./UIEventSource"; + +export default class ContributorCount { + + public readonly Contributors: UIEventSource>; + + constructor(featureSource: FeatureSource) { + this.Contributors = featureSource.features.map(features => { + const hist = new Map(); + for (const feature of features) { + const contributor = feature.feature.properties["_last_edit:contributor"] + const count = hist.get(contributor) ?? 0; + hist.set(contributor, count + 1) + } + return hist; + }) + } + +} \ No newline at end of file