Feat: panoramax uploads in testmode are sent to a different sequence

This commit is contained in:
Pieter Vander Vennet 2024-10-23 18:58:47 +02:00
parent 40eceafc80
commit 834b6b18ff
4 changed files with 13 additions and 8 deletions

View file

@ -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",

View file

@ -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<string>
constructor(url: string, token: string) {
constructor(url: string, token: string, targetSequence: Store<string>) {
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 = <ImageData>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 = <ImageData>await p.addImage(blob, sequence, {
lon,
lat,
datetime,

View file

@ -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 = {

View file

@ -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,