From fcd3e3c5881e4e179612d3d06ae06f7a2e1ba34f Mon Sep 17 00:00:00 2001 From: pietervdvn Date: Mon, 14 Mar 2022 01:37:50 +0100 Subject: [PATCH] Use different query to pickup changesets where 'created_by' is missing --- Docs/Tools/GenerateSeries.ts | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/Docs/Tools/GenerateSeries.ts b/Docs/Tools/GenerateSeries.ts index 855c7ca5bf..dc53d04fa1 100644 --- a/Docs/Tools/GenerateSeries.ts +++ b/Docs/Tools/GenerateSeries.ts @@ -1,4 +1,4 @@ -import {existsSync, readdirSync, readFileSync, writeFileSync} from "fs"; +import {existsSync, mkdirSync, readdirSync, readFileSync, writeFileSync} from "fs"; import ScriptUtils from "../../scripts/ScriptUtils"; import {Utils} from "../../Utils"; import {exec} from "child_process" @@ -10,9 +10,11 @@ class StatsDownloader { private readonly startYear = 2020 private readonly startMonth = 5; - private readonly urlTemplate = "https://osmcha.org/api/v1/changesets/?date__gte={start_date}&date__lte={end_date}&page={page}&editor=mapcomplete&page_size=100" + private readonly urlTemplate = "https://osmcha.org/api/v1/changesets/?date__gte={start_date}&date__lte={end_date}&page={page}&comment=%23mapcomplete&page_size=100" + private readonly _targetDirectory: string; + constructor(targetDirectory = ".") { this._targetDirectory = targetDirectory; @@ -614,7 +616,7 @@ function createGraphs(allFeatures: ChangeSetData[], appliedFilterDescription: st Group.createStackedBarChartPerDay( "Changesets per version number" + appliedFilterDescription, allFeatures, - f => f.properties.editor.substr("MapComplete ".length, 6).replace(/[a-zA-Z-/]/g, ''), + f => f.properties.editor?.substr("MapComplete ".length, 6)?.replace(/[a-zA-Z-/]/g, '') ?? "UNKNOWN", cutoff ?? 1 ) @@ -622,7 +624,7 @@ function createGraphs(allFeatures: ChangeSetData[], appliedFilterDescription: st "Changesets per minor version number" + appliedFilterDescription, allFeatures, f => { - const base = f.properties.editor.substr("MapComplete ".length).replace(/[a-zA-Z-/]/g, '') + const base = f.properties.editor?.substr("MapComplete ".length)?.replace(/[a-zA-Z-/]/g, '') ?? "UNKNOWN" const [major, minor, patch] = base.split(".") return major+"."+minor @@ -701,6 +703,10 @@ function createMiscGraphs(allFeatures: ChangeSetData[], emptyCS: ChangeSetData[] } async function main(): Promise{ + if(!existsSync("graphs")){ + mkdirSync("graphs") + } + await new StatsDownloader("stats").DownloadStats() const allPaths = readdirSync("stats") .filter(p => p.startsWith("stats.") && p.endsWith(".json"));