Skip to content

Commit

Permalink
feat: count with csr
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasBousselin committed Dec 12, 2024
1 parent 24c0cd4 commit d42dd4b
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ import org.springframework.web.bind.annotation.RequestParam
import org.springframework.web.bind.annotation.RestController
import reactor.core.publisher.Mono
import java.net.URI
import kotlin.math.max

@RestController
@RequestMapping("/ngsi-ld/v1/entities")
Expand Down Expand Up @@ -261,6 +262,8 @@ class EntityHandler(
// todo is it possible to have a non blocking error ? (like the 404 for the retrieve)
val (localEntities, localCount) = localResponse.bind()

val maxCount = max(localCount, remoteCounts.maxBy { it ?: 0 } ?: 0)

val (mergeWarnings, mergedEntities) = ContextSourceUtils.mergeEntitiesLists(
localEntities,
remoteEntitiesWithCSR
Expand All @@ -276,7 +279,7 @@ class EntityHandler(
val ngsiLdDataRepresentation = parseRepresentations(queryParams, mediaType)
buildQueryResponse(
mergedEntities.toFinalRepresentation(ngsiLdDataRepresentation),
localCount,
maxCount,
"/ngsi-ld/v1/entities",
entitiesQuery.paginationQuery,
queryParams,
Expand Down

0 comments on commit d42dd4b

Please sign in to comment.