Skip to content

Commit

Permalink
Merge pull request #801 from wellcomecollection/fix-deepstoreItemAvai…
Browse files Browse the repository at this point in the history
…labilities-list

compare dates without time + better tests data -take 2
  • Loading branch information
agnesgaroux authored Aug 8, 2024
2 parents 91ddf27 + 75e9853 commit fe028ec
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 49 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
}
Expand All @@ -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")
)

}
Original file line number Diff line number Diff line change
Expand Up @@ -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(",")
Expand All @@ -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
)
}

Expand Down Expand Up @@ -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"
}
]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit fe028ec

Please sign in to comment.