From 834b6b18ff985cd1a79e725af915e307525d221e Mon Sep 17 00:00:00 2001 From: Pieter Vander Vennet Date: Wed, 23 Oct 2024 18:58:47 +0200 Subject: [PATCH] Feat: panoramax uploads in testmode are sent to a different sequence --- package.json | 3 ++- src/Logic/ImageProviders/Panoramax.ts | 12 +++++++----- src/Models/Constants.ts | 2 +- src/Models/ThemeViewState.ts | 4 +++- 4 files changed, 13 insertions(+), 8 deletions(-) diff --git a/package.json b/package.json index 4f3edb1d6..4e04e6ff0 100644 --- a/package.json +++ b/package.json @@ -43,7 +43,8 @@ "panoramax": { "url": "https://panoramax.mapcomplete.org", "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnZW92aXNpbyIsInN1YiI6IjU5ZjgzOGI0LTM4ZjAtNDdjYi04OWYyLTM3NDQ3MWMxNTUxOCJ9.0rBioZS_48NTjnkIyN9497c3fQdTqtGgH1HDqlz1bWs", - "sequence": "6e702976-580b-419c-8fb3-cf7bd364e6f8" + "sequence": "6e702976-580b-419c-8fb3-cf7bd364e6f8", + "testsequence": "7f34cf53-27ff-46c9-ac22-78511fa8457a" }, "default_overpass_urls": [ "https://overpass-api.de/api/interpreter", diff --git a/src/Logic/ImageProviders/Panoramax.ts b/src/Logic/ImageProviders/Panoramax.ts index f79c27161..6b2379631 100644 --- a/src/Logic/ImageProviders/Panoramax.ts +++ b/src/Logic/ImageProviders/Panoramax.ts @@ -171,8 +171,10 @@ export default class PanoramaxImageProvider extends ImageProvider { export class PanoramaxUploader implements ImageUploader { public readonly panoramax: AuthorizedPanoramax maxFileSizeInMegabytes = 100 * 1000 * 1000 // 100MB + private readonly _targetSequence: Store - constructor(url: string, token: string) { + constructor(url: string, token: string, targetSequence: Store) { + this._targetSequence = targetSequence this.panoramax = new AuthorizedPanoramax(url, token) } @@ -208,10 +210,10 @@ export class PanoramaxUploader implements ImageUploader { const p = this.panoramax - const defaultSequence: {id: string, "stats:items":{count:number}} = - (await p.mySequences()).find(s => s.id === Constants.panoramax.sequence) - console.log("Upload options are", lon, lat, datetime, blob) - const img = await p.addImage(blob, defaultSequence, { + sequenceId ??= this._targetSequence?.data ?? Constants.panoramax.sequence + const sequence: {id: string, "stats:items":{count:number}} = + (await p.mySequences()).find(s => s.id === sequenceId) + const img = await p.addImage(blob, sequence, { lon, lat, datetime, diff --git a/src/Models/Constants.ts b/src/Models/Constants.ts index eb2a36c2d..ab3516f3b 100644 --- a/src/Models/Constants.ts +++ b/src/Models/Constants.ts @@ -50,7 +50,7 @@ export default class Constants { ...Constants.no_include, ] as const - public static panoramax: { url: string; token: string, sequence: string } = packagefile.config.panoramax + public static panoramax: { url: string; token: string, sequence: string, testsequence: string } = packagefile.config.panoramax // The user journey states thresholds when a new feature gets unlocked public static userJourney = { diff --git a/src/Models/ThemeViewState.ts b/src/Models/ThemeViewState.ts index 6a45af1e3..a7656963a 100644 --- a/src/Models/ThemeViewState.ts +++ b/src/Models/ThemeViewState.ts @@ -373,7 +373,9 @@ export default class ThemeViewState implements SpecialVisualizationState { this.hasDataInView = new NoElementsInViewDetector(this).hasFeatureInView this.imageUploadManager = new ImageUploadManager( layout, - new PanoramaxUploader(Constants.panoramax.url, Constants.panoramax.token), + new PanoramaxUploader(Constants.panoramax.url, Constants.panoramax.token, + this.featureSwitchIsTesting.map(t => t ? Constants.panoramax.testsequence : Constants.panoramax.sequence) + ), this.featureProperties, this.osmConnection, this.changes,