Skip to content

Commit

Permalink
PIN-5010: Move pagination to upstream query (#84)
Browse files Browse the repository at this point in the history
  • Loading branch information
galales authored Jun 18, 2024
1 parent 1c47465 commit c69edcf
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ class DynamoNotificationService(scanamo: ScanamoAsync) {
): Future[List[NotificationMessage]] = {
logger.debug(s"Getting $limit events for organization $organizationId from $eventId")
val operations: ScanamoOps[List[Either[DynamoReadError, NotificationMessage]]] =
messages.query("organizationId" === organizationId and "eventId" > eventId)
messages.limit(limit).query("organizationId" === organizationId and "eventId" > eventId)
scanamo.exec(operations).map(_.sequence).flatMap {
case Right(x) =>
logger.debug(s"${x.size} messages retrieved from Dynamo")
Future.successful(x.take(limit)) // TODO consider improving this using the limit upstream
Future.successful(x)
case Left(err) => Future.failed(DynamoReadingError(describe(err)))
}
}
Expand Down

0 comments on commit c69edcf

Please sign in to comment.