Skip to content

Commit 48524c4

Browse files
committed
Latest notified retrieval
1 parent cc92d56 commit 48524c4

File tree

2 files changed

+33
-3
lines changed

2 files changed

+33
-3
lines changed

src/main/scala/za/co/absa/statusboard/repository/DynamoDbStatusRepository.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ class DynamoDbStatusRepository(dynamodbClient: DynamoDbClient, tableName: String
139139
baseBuilder
140140

141141
maybeFilteredBuilder.scanIndexForward(false)
142-
.limit(1)
142+
// no limit - as it would be applied before the filter
143143
.build()
144144
}
145145
response <- ZIO.attempt(dynamodbClient.query(request))

src/test/scala/za/co/absa/statusboard/repository/DynamoDbStatusRepositoryDynamoDBIntegrationTests.scala

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import za.co.absa.statusboard.config.RepositoriesConfig
2121
import za.co.absa.statusboard.model.AppError.DatabaseError.RecordNotFoundDatabaseError
2222
import za.co.absa.statusboard.model.{RawStatus, RefinedStatus}
2323
import za.co.absa.statusboard.providers.DynamoDbProvider
24-
import za.co.absa.statusboard.testUtils.TestData.rawStatusRed
24+
import za.co.absa.statusboard.testUtils.TestData.{rawStatusGreen, rawStatusRed}
2525
import za.co.absa.statusboard.testUtils.{ConfigProviderSpec, TestData}
2626
import za.co.absa.statusboard.utils.DynamoDbUtils.DynamoDbExtensions
2727
import zio._
@@ -52,7 +52,6 @@ object DynamoDbStatusRepositoryDynamoDBIntegrationTests extends ConfigProviderSp
5252
status = RawStatus.Black(),
5353
serviceName = "Dead Test Service")
5454

55-
5655
override def spec: Spec[TestEnvironment with Scope, Any] = {
5756
suite("DynamoDbStatusRepositorySuite")(
5857
test("getLatestStatus should retrieve nothing when no state exist") {
@@ -167,6 +166,37 @@ object DynamoDbStatusRepositoryDynamoDBIntegrationTests extends ConfigProviderSp
167166
assertZIO(StatusRepository.getLatestStatusOfAllActiveConfigurations())(
168167
equalTo(Set(refinedStatusAnotherService, refinedStatusAnotherRenamed))
169168
)
169+
},
170+
test("BUG #10 Latest Notified Retrieval 2025-06-11") {
171+
val refinedStatus_A: RefinedStatus = RefinedStatus(
172+
serviceName = "BugService",
173+
env = "BUG #10",
174+
status = RawStatus.Green("1 FAIL"),
175+
maintenanceMessage = "",
176+
firstSeen = Instant.parse("2025-05-21T12:14:42.030Z"),
177+
lastSeen = Instant.parse("2025-05-21T12:16:31.711Z"),
178+
notificationSent = true
179+
)
180+
181+
val refinedStatus_B: RefinedStatus = refinedStatus_A.copy(
182+
status = RawStatus.Green("2 OK"),
183+
firstSeen = Instant.parse("2025-05-21T12:17:08.006Z"),
184+
lastSeen = Instant.parse("2025-06-11T02:00:21.191Z"),
185+
notificationSent = true
186+
)
187+
188+
val refinedStatus_C: RefinedStatus = refinedStatus_A.copy(
189+
status = RawStatus.Red("3 FAIL", true),
190+
firstSeen = Instant.parse("2025-06-11T02:10:41.219Z"),
191+
lastSeen = Instant.parse("2025-06-11T02:10:41.219Z"),
192+
notificationSent = false
193+
)
194+
for {
195+
_ <- StatusRepository.createOrUpdate(refinedStatus_A)
196+
_ <- StatusRepository.createOrUpdate(refinedStatus_B)
197+
_ <- StatusRepository.createOrUpdate(refinedStatus_C)
198+
result <- StatusRepository.getLatestNotifiedStatus("BUG #10", "BugService")
199+
} yield assert(result.status)(equalTo(RawStatus.Green("2 OK")))
170200
}
171201
) @@
172202
TestAspect.sequential @@

0 commit comments

Comments
 (0)