diff --git a/items/src/main/scala/weco/api/items/services/SierraItemUpdater.scala b/items/src/main/scala/weco/api/items/services/SierraItemUpdater.scala index 0dcf3e176..bb16a2050 100644 --- a/items/src/main/scala/weco/api/items/services/SierraItemUpdater.scala +++ b/items/src/main/scala/weco/api/items/services/SierraItemUpdater.scala @@ -162,10 +162,7 @@ class SierraItemUpdater( ): List[AvailabilitySlot] = { val timeAtVenue = LocalDateTime.now(venueClock) val isWorkingDay = timeAtVenue.toLocalDate.isEqual( - LocalDate.parse( - venuesOpeningTimes("library").head.from, - DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSSXXX") - ) + parseISOStringToLocalDate(venuesOpeningTimes("library").head.from) ) if (timeAtVenue.getHour < 10 | !isWorkingDay) { venuesOpeningTimes("library").drop(1) @@ -185,7 +182,11 @@ class SierraItemUpdater( val subsequentLibraryAvailabilitySlots = venuesOpeningTimes( "library" ).filter( - openingTime => openingTime.from > firstDeepstoreAvailabilitySlot.from + openingTime => + parseISOStringToLocalDate(openingTime.from) + .isAfter( + parseISOStringToLocalDate(firstDeepstoreAvailabilitySlot.from) + ) ) firstDeepstoreAvailabilitySlot :: subsequentLibraryAvailabilitySlots } @@ -209,4 +210,11 @@ class SierraItemUpdater( } yield updatedItems } } + + private def parseISOStringToLocalDate(isoString: String): LocalDate = + LocalDate.parse( + isoString, + DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSSXXX") + ) + } diff --git a/items/src/test/scala/weco/api/items/fixtures/ItemsApiGenerators.scala b/items/src/test/scala/weco/api/items/fixtures/ItemsApiGenerators.scala index e9a010572..a10104d21 100644 --- a/items/src/test/scala/weco/api/items/fixtures/ItemsApiGenerators.scala +++ b/items/src/test/scala/weco/api/items/fixtures/ItemsApiGenerators.scala @@ -15,19 +15,19 @@ trait ItemsApiGenerators extends LocalResources { holdCount: Int = 0, locationCode: String = "some-location-code" ) = f""" - |{ - | "id": "${sierraItemNumber.withoutCheckDigit}", - | "deleted": $deleted, - | "suppressed": $suppressed, - | "fixedFields": { - | "79": {"label": "LOCATION", "value": "scmwf", "display": "Closed stores A&MSS Well.Found."}, - | "88": {"label": "STATUS", "value": "-", "display": "Available"}, - | "108": {"label": "OPACMSG", "value": "f", "display": "Online request"} - | }, - | "holdCount": $holdCount, - | "location": {"code": "$locationCode", "name": "some-location-name"} - |} - |""".stripMargin + |{ + | "id": "${sierraItemNumber.withoutCheckDigit}", + | "deleted": $deleted, + | "suppressed": $suppressed, + | "fixedFields": { + | "79": {"label": "LOCATION", "value": "scmwf", "display": "Closed stores A&MSS Well.Found."}, + | "88": {"label": "STATUS", "value": "-", "display": "Available"}, + | "108": {"label": "OPACMSG", "value": "f", "display": "Online request"} + | }, + | "holdCount": $holdCount, + | "location": {"code": "$locationCode", "name": "some-location-name"} + |} + |""".stripMargin def sierraItemRequest(itemNumber: SierraItemNumber): HttpRequest = { val fieldList = SierraSource.requiredItemFields.mkString(",") @@ -54,14 +54,14 @@ trait ItemsApiGenerators extends LocalResources { HttpEntity( contentType = ContentTypes.`application/json`, f""" - |{ - | "total": ${entries.length}, - | "start": 0, - | "entries": [ - | $entries - | ] - |} - |""".stripMargin + |{ + | "total": ${entries.length}, + | "start": 0, + | "entries": [ + | $entries + | ] + |} + |""".stripMargin ) } @@ -194,48 +194,48 @@ trait ItemsApiGenerators extends LocalResources { "title": "$venueName", "nextOpeningDates": [ { - "open": "2024-04-24T09:00:00.000Z", - "close": "2024-04-24T17:00:00.000Z" + "open": "2024-04-24T08:00:00.000Z", + "close": "2024-04-24T15:00:00.000Z" }, { - "open": "2024-04-25T09:00:00.000Z", + "open": "2024-04-25T08:00:00.000Z", "close": "2024-04-25T19:00:00.000Z" }, { - "open": "2024-04-26T09:00:00.000Z", - "close": "2024-04-26T17:00:00.000Z" + "open": "2024-04-26T08:00:00.000Z", + "close": "2024-04-26T15:00:00.000Z" }, { - "open": "2024-04-27T09:00:00.000Z", - "close": "2024-04-27T17:00:00.000Z" + "open": "2024-04-27T08:00:00.000Z", + "close": "2024-04-27T15:00:00.000Z" }, { - "open": "2024-04-28T09:00:00.000Z", - "close": "2024-04-28T17:00:00.000Z" + "open": "2024-04-28T08:00:00.000Z", + "close": "2024-04-28T15:00:00.000Z" }, { - "open": "2024-04-29T09:00:00.000Z", - "close": "2024-04-29T17:00:00.000Z" + "open": "2024-04-29T08:00:00.000Z", + "close": "2024-04-29T15:00:00.000Z" }, { - "open": "2024-04-30T09:00:00.000Z", - "close": "2024-04-30T17:00:00.000Z" + "open": "2024-04-30T08:00:00.000Z", + "close": "2024-04-30T15:00:00.000Z" }, { - "open": "2024-05-01T09:00:00.000Z", - "close": "2024-05-01T17:00:00.000Z" + "open": "2024-05-01T08:00:00.000Z", + "close": "2024-05-01T15:00:00.000Z" }, { - "open": "2024-05-02T09:00:00.000Z", - "close": "2024-05-02T17:00:00.000Z" + "open": "2024-05-02T08:00:00.000Z", + "close": "2024-05-02T15:00:00.000Z" }, { - "open": "2024-05-03T09:00:00.000Z", - "close": "2024-05-03T17:00:00.000Z" + "open": "2024-05-03T08:00:00.000Z", + "close": "2024-05-03T15:00:00.000Z" }, { - "open": "2024-05-04T09:00:00.000Z", - "close": "2024-05-04T17:00:00.000Z" + "open": "2024-05-04T08:00:00.000Z", + "close": "2024-05-04T15:00:00.000Z" } ] } diff --git a/items/src/test/scala/weco/api/items/services/SierraItemUpdaterTest.scala b/items/src/test/scala/weco/api/items/services/SierraItemUpdaterTest.scala index df394ab98..d60c279a5 100644 --- a/items/src/test/scala/weco/api/items/services/SierraItemUpdaterTest.scala +++ b/items/src/test/scala/weco/api/items/services/SierraItemUpdaterTest.scala @@ -442,8 +442,8 @@ class SierraItemUpdaterTest physicalItem.availableDates shouldBe Some( List( AvailabilitySlot( - "2024-05-04T09:00:00.000Z", - "2024-05-04T17:00:00.000Z" + "2024-05-04T08:00:00.000Z", + "2024-05-04T15:00:00.000Z" ), AvailabilitySlot( "2024-05-05T09:00:00.000Z",