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
This commit is contained in:
2026-02-28 23:09:09 +01:00
parent 4caadd24b9
commit 02c33e5ad5
3 changed files with 17 additions and 14 deletions

View File

@@ -1,9 +1,14 @@
query MapMarkers($isOnline: Boolean!) { query MapMarkers($isOnline: Boolean!) {
getMarkers(filter: { isOnline: $isOnline }) { locations(filter: { isOnline: $isOnline }) {
_id _id
name name
city
isOnline
latitude latitude
longitude longitude
text metricList
currentValue {
PMS25
}
} }
} }

View File

@@ -5,17 +5,15 @@ import org.db3.airmq.sdk.MapMarkersQuery
import org.db3.airmq.sdk.map.domain.MapItem import org.db3.airmq.sdk.map.domain.MapItem
class ApolloMapItemMapper @Inject constructor() { class ApolloMapItemMapper @Inject constructor() {
fun toDomain(marker: MapMarkersQuery.GetMarker, index: Int): MapItem? { fun toDomain(location: MapMarkersQuery.Location, index: Int): MapItem? {
val latitude = marker.latitude ?: return null val id = location._id.ifBlank { "location-$index" }
val longitude = marker.longitude ?: return null
val id = marker._id?.ifBlank { null } ?: "marker-$index"
return MapItem( return MapItem(
id = id, id = id,
title = marker.name?.ifBlank { null } ?: marker.text?.ifBlank { null } ?: id, title = location.name.ifBlank { id },
city = null, city = location.city?.ifBlank { null },
latitude = latitude, latitude = location.latitude,
longitude = longitude, longitude = location.longitude,
isOnline = false isOnline = location.isOnline ?: false
) )
} }
} }

View File

@@ -21,10 +21,10 @@ class MapServiceImpl @Inject constructor(
throw IllegalStateException(gqlError.message) throw IllegalStateException(gqlError.message)
} }
val mappedItems = response.data?.getMarkers val mappedItems = response.data?.locations
.orEmpty() .orEmpty()
.filterNotNull() .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") Log.d(TAG, "MapMarkers Apollo query returned ${mappedItems.size} items")
return mappedItems return mappedItems
} }