stellio-hub / stellio-context-broker

Stellio is an NGSI-LD compatible context broker
https://stellio.readthedocs.io
Apache License 2.0
25 stars 11 forks source link

Querying temporal entities does not honor `lastN` parameter when aggregated values are asked #1150

Closed ranim-n closed 1 month ago

ranim-n commented 2 months ago

when querying a temporal entity with lastN , timerel , timeAt and aggrPeriodDuration parameters we are expected to get n attribute instances corresponding to the last n timestamps (from the most recent to the least recent timestamp in the requested time range). But instead, Stellio returns more results than expected.

bobeal commented 2 months ago

Looking at https://github.com/stellio-hub/stellio-context-broker/blob/develop/search-service/src/main/kotlin/com/egm/stellio/search/service/AttributeInstanceService.kt#L161, the lastN parameter is applied only if not in aggregated operation. Guess the else if should be an if.

Same applies for the history of scopes: https://github.com/stellio-hub/stellio-context-broker/blob/develop/search-service/src/main/kotlin/com/egm/stellio/search/scope/ScopeService.kt#L116