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 }