From 02c33e5ad5f1e278adb5ecdc319bae8861646dd8 Mon Sep 17 00:00:00 2001 From: beetzung Date: Sat, 28 Feb 2026 23:09:09 +0100 Subject: [PATCH] Update map marker mapping for locations query. Switch MapMarkers handling from getMarkers to locations, and align mapper fields with the new Location payload while preserving MapItem coordinates and online status. Made-with: Cursor --- sdk/src/main/graphql/MapLocations.graphql | 11 ++++++++--- .../org/db3/airmq/sdk/map/ApolloMapItemMapper.kt | 16 +++++++--------- .../org/db3/airmq/sdk/map/MapServiceImpl.kt | 4 ++-- 3 files changed, 17 insertions(+), 14 deletions(-) diff --git a/sdk/src/main/graphql/MapLocations.graphql b/sdk/src/main/graphql/MapLocations.graphql index e1b3bf3..1e52753 100644 --- a/sdk/src/main/graphql/MapLocations.graphql +++ b/sdk/src/main/graphql/MapLocations.graphql @@ -1,9 +1,14 @@ query MapMarkers($isOnline: Boolean!) { - getMarkers(filter: { isOnline: $isOnline }) { + locations(filter: { isOnline: $isOnline }) { _id name + city + isOnline latitude longitude - text + metricList + currentValue { + PMS25 + } } -} +} \ No newline at end of file diff --git a/sdk/src/main/kotlin/org/db3/airmq/sdk/map/ApolloMapItemMapper.kt b/sdk/src/main/kotlin/org/db3/airmq/sdk/map/ApolloMapItemMapper.kt index 7f6da1b..4471a96 100644 --- a/sdk/src/main/kotlin/org/db3/airmq/sdk/map/ApolloMapItemMapper.kt +++ b/sdk/src/main/kotlin/org/db3/airmq/sdk/map/ApolloMapItemMapper.kt @@ -5,17 +5,15 @@ import org.db3.airmq.sdk.MapMarkersQuery import org.db3.airmq.sdk.map.domain.MapItem class ApolloMapItemMapper @Inject constructor() { - fun toDomain(marker: MapMarkersQuery.GetMarker, index: Int): MapItem? { - val latitude = marker.latitude ?: return null - val longitude = marker.longitude ?: return null - val id = marker._id?.ifBlank { null } ?: "marker-$index" + fun toDomain(location: MapMarkersQuery.Location, index: Int): MapItem? { + val id = location._id.ifBlank { "location-$index" } return MapItem( id = id, - title = marker.name?.ifBlank { null } ?: marker.text?.ifBlank { null } ?: id, - city = null, - latitude = latitude, - longitude = longitude, - isOnline = false + title = location.name.ifBlank { id }, + city = location.city?.ifBlank { null }, + latitude = location.latitude, + longitude = location.longitude, + isOnline = location.isOnline ?: false ) } } diff --git a/sdk/src/main/kotlin/org/db3/airmq/sdk/map/MapServiceImpl.kt b/sdk/src/main/kotlin/org/db3/airmq/sdk/map/MapServiceImpl.kt index 74c5856..2652cf7 100644 --- a/sdk/src/main/kotlin/org/db3/airmq/sdk/map/MapServiceImpl.kt +++ b/sdk/src/main/kotlin/org/db3/airmq/sdk/map/MapServiceImpl.kt @@ -21,10 +21,10 @@ class MapServiceImpl @Inject constructor( throw IllegalStateException(gqlError.message) } - val mappedItems = response.data?.getMarkers + val mappedItems = response.data?.locations .orEmpty() .filterNotNull() - .mapIndexedNotNull { index, marker -> mapper.toDomain(marker, index) } + .mapIndexedNotNull { index, location -> mapper.toDomain(location, index) } Log.d(TAG, "MapMarkers Apollo query returned ${mappedItems.size} items") return mappedItems }