Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dependency updates #765

Merged
merged 23 commits into from
Oct 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
5a0eb8f
Update sbt-bloop to 1.6.0
wellcome-collection-scala-steward[bot] Sep 4, 2024
280ba0f
Update fm-sbt-s3-resolver to 0.22.0
wellcome-collection-scala-steward[bot] Sep 4, 2024
e332660
Update scalacheck-shapeless_1.13 to 1.1.8
wellcome-collection-scala-steward[bot] Sep 4, 2024
b0e2ada
Update scala-csv to 1.3.10
wellcome-collection-scala-steward[bot] Sep 4, 2024
80cf67c
Update sbt-scalafmt to 1.16
wellcome-collection-scala-steward[bot] Sep 4, 2024
4bfd6a3
Update sbt-docker-compose to 1.0.35
wellcome-collection-scala-steward[bot] Sep 4, 2024
fd10b06
Update sbt-git to 1.0.2
wellcome-collection-scala-steward[bot] Sep 4, 2024
2c1201c
Update sbt-native-packager to 1.3.25
wellcome-collection-scala-steward[bot] Sep 4, 2024
9c6a80a
Update sbt-revolver to 0.10.0
wellcome-collection-scala-steward[bot] Sep 4, 2024
9e1f4c0
Update pekko-testkit to 1.1.0
wellcome-collection-scala-steward[bot] Sep 4, 2024
6e18ef5
Update scala-library to 2.12.19
wellcome-collection-scala-steward[bot] Sep 4, 2024
77496c5
Update sbt to 1.9.9
wellcome-collection-scala-steward[bot] Sep 4, 2024
97954bf
Update scalafmt-core to 2.7.5
wellcome-collection-scala-steward[bot] Sep 4, 2024
22f65b4
Reformat with scalafmt 2.7.5
wellcome-collection-scala-steward[bot] Sep 4, 2024
c47d894
Add 'Reformat with scalafmt 2.7.5' to .git-blame-ignore-revs
wellcome-collection-scala-steward[bot] Sep 4, 2024
064f949
Update scalatest to 3.2.19
wellcome-collection-scala-steward[bot] Sep 4, 2024
f9dff3a
Update scalacheck-1-14 to 3.1.4.0
wellcome-collection-scala-steward[bot] Sep 4, 2024
c3ea40a
Merge branch 'main' into update/non_aws
StepanBrychta Oct 3, 2024
0671f26
Update Dependencies.scala
StepanBrychta Oct 4, 2024
affcc40
Apply auto-formatting rules
weco-bot Oct 4, 2024
b1a866e
Update Dependencies.scala
StepanBrychta Oct 4, 2024
4463a19
Merge branch 'update/non_aws' of https://github.com/wellcomecollectio…
StepanBrychta Oct 4, 2024
0c86a8c
Update Dependencies.scala
StepanBrychta Oct 7, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Scala Steward: Reformat with scalafmt 2.7.5
22f65b437f4885b5058aeca090a7fa46c16cbbee
2 changes: 1 addition & 1 deletion .scalafmt.conf
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Matches the version here
# https://github.com/wellcomecollection/dockerfiles/blob/master/scalafmt/Dockerfile#L11
version = "2.0.0"
version = "2.7.5"
align.openParenCallSite = false
continuationIndent.defnSite = 2
rewrite.rules = [SortImports, RedundantBraces]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,10 @@ object PipelineElasticClientBuilder {
"public_host",
secretsManagerClientBuilder
.credentialsProvider(
ProfileCredentialsProvider.create("catalogue-developer"))
.build())
ProfileCredentialsProvider.create("catalogue-developer")
)
.build()
)
case _ =>
("private_host", secretsManagerClientBuilder.build())
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@ package weco.catalogue.source_model.sierra.rules

import grizzled.slf4j.Logging
import weco.api.stacks.models.{CatalogueAccessMethod, CatalogueLocationType}
import weco.catalogue.display_model.locations.{CatalogueAccessStatus, DisplayAccessCondition, DisplayLocationType}
import weco.catalogue.display_model.locations.{
CatalogueAccessStatus,
DisplayAccessCondition,
DisplayLocationType
}
import weco.catalogue.source_model.sierra.source.{OpacMsg, Status}
import weco.sierra.models.SierraQueryOps
import weco.sierra.models.data.SierraItemData
Expand All @@ -22,7 +26,6 @@ import weco.sierra.models.data.SierraItemData
*
* We remove rules that would end in a "definitely not requestable" state, because
* those items should be filtered out by the front end.
*
*/
object SierraItemAccess extends SierraQueryOps with Logging {
def apply(
Expand All @@ -48,10 +51,10 @@ object SierraItemAccess extends SierraQueryOps with Logging {
//
// Otherwise, we copy the item note onto the access condition.
case (Some(ac), Some(displayNote))
if ac.note.isDefined && displayNote.isAccessNote =>
if ac.note.isDefined && displayNote.isAccessNote =>
(Some(ac), None)
case (Some(ac), Some(displayNote))
if ac.note.isEmpty && displayNote.isAccessNote =>
if ac.note.isEmpty && displayNote.isAccessNote =>
(Some(ac.copy(note = Some(displayNote))), None)

// If the item note is nothing to do with the access condition, we return it to
Expand All @@ -68,18 +71,25 @@ object SierraItemAccess extends SierraQueryOps with Logging {
locationTypeId: Option[String],
itemData: SierraItemData
): Option[DisplayAccessCondition] =
(holdCount, status, opacmsg, rulesForRequestingResult, locationTypeId) match {
(
holdCount,
status,
opacmsg,
rulesForRequestingResult,
locationTypeId
) match {

// Items in the closed stores that aren't prevented from being requested get
// the "Online request" condition.
//
// Example: b18799966 / i17571170
case (
Some(0),
Some(Status.Available),
Some(OpacMsg.OnlineRequest),
None,
Some(CatalogueLocationType.ClosedStores)) =>
Some(0),
Some(Status.Available),
Some(OpacMsg.OnlineRequest),
None,
Some(CatalogueLocationType.ClosedStores)
) =>
Some(
DisplayAccessCondition(
method = CatalogueAccessMethod.OnlineRequest,
Expand All @@ -92,11 +102,12 @@ object SierraItemAccess extends SierraQueryOps with Logging {
//
// Example: b29459126 / i19023340
case (
Some(0),
Some(Status.Available),
Some(OpacMsg.Restricted),
None,
Some(CatalogueLocationType.ClosedStores)) =>
Some(0),
Some(Status.Available),
Some(OpacMsg.Restricted),
None,
Some(CatalogueLocationType.ClosedStores)
) =>
Some(
DisplayAccessCondition(
method = CatalogueAccessMethod.OnlineRequest,
Expand All @@ -118,30 +129,32 @@ object SierraItemAccess extends SierraQueryOps with Logging {
// for requesting, e.g. some of our long-lived test holds didn't get cleared properly.
// If an item seems to be stuck on a non-zero hold count, ask somebody to check Sierra.
case (Some(holdCount), _, _, _, Some(CatalogueLocationType.ClosedStores))
if holdCount > 0 =>
if holdCount > 0 =>
Some(
DisplayAccessCondition(
method = CatalogueAccessMethod.NotRequestable,
status = Some(CatalogueAccessStatus.TemporarilyUnavailable),
note = Some(
"Item is in use by another reader. Please ask at Library Enquiry Desk."),
"Item is in use by another reader. Please ask at Library Enquiry Desk."
),
terms = None
)
)


case (
_,
_,
_,
Some(NotRequestable.InUseByAnotherReader(_)),
Some(CatalogueLocationType.ClosedStores)) =>
_,
_,
_,
Some(NotRequestable.InUseByAnotherReader(_)),
Some(CatalogueLocationType.ClosedStores)
) =>
Some(
DisplayAccessCondition(
method = CatalogueAccessMethod.NotRequestable,
status = Some(CatalogueAccessStatus.TemporarilyUnavailable),
note = Some(
"Item is in use by another reader. Please ask at Library Enquiry Desk."),
"Item is in use by another reader. Please ask at Library Enquiry Desk."
),
terms = None
)
)
Expand All @@ -160,10 +173,10 @@ object SierraItemAccess extends SierraQueryOps with Logging {

implicit class ItemDataAccessOps(itemData: SierraItemData) {
def status: Option[String] =
itemData.fixedFields.get("88").map { _.value.trim }
itemData.fixedFields.get("88").map(_.value.trim)

def opacmsg: Option[String] =
itemData.fixedFields.get("108").map { _.value.trim }
itemData.fixedFields.get("108").map(_.value.trim)
}

// The display note field has been used for multiple purposes, in particular:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import weco.sierra.models.data.SierraItemData
*
* We remove rules that would end in a "definitely not requestable" state, because
* those items should be filtered out by the front end.
*
*/
object SierraRulesForRequesting {
def apply(itemData: SierraItemData): Option[NotRequestable] =
Expand All @@ -45,19 +44,20 @@ object SierraRulesForRequesting {
// for now. TODO: Find an example of this.
//
case i
if i.fixedField("87").getOrElse("0") != "0" || i
.fixedField("88")
.contains("!") =>
if i.fixedField("87").getOrElse("0") != "0" || i
.fixedField("88")
.contains("!") =>
Some(
NotRequestable.InUseByAnotherReader(
"Item is in use by another reader. Please ask at Enquiry Desk.")
"Item is in use by another reader. Please ask at Enquiry Desk."
)
)

case _ => None
}

private implicit class ItemDataOps(itemData: SierraItemData) {
def fixedField(code: String): Option[String] =
itemData.fixedFields.get(code).map { _.value.trim }
itemData.fixedFields.get(code).map(_.value.trim)
}
}
7 changes: 3 additions & 4 deletions items/src/main/scala/weco/api/items/ItemsApi.scala
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,10 @@ import scala.concurrent.ExecutionContext
class ItemsApi(
val itemUpdateService: ItemUpdateService,
val workLookup: WorkLookup
)(
implicit
)(implicit
val ec: ExecutionContext,
val apiConfig: ApiConfig
) extends LookupItemStatus
val apiConfig: ApiConfig)
extends LookupItemStatus
with IdentifierDirectives
with FutureDirectives
with Tracing {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ object SierraOauthHttpClientBuilder {
def build(config: Config, environment: ApiEnvironment = ApiEnvironment.Prod)(
implicit
as: ActorSystem,
ec: ExecutionContext,
ec: ExecutionContext
): SierraOauthHttpClient = {

val secretsManagerClientBuilder = SecretsManagerClient.builder()
Expand All @@ -32,7 +32,8 @@ object SierraOauthHttpClientBuilder {
case ApiEnvironment.Dev =>
secretsManagerClientBuilder
.credentialsProvider(
ProfileCredentialsProvider.create("catalogue-developer"))
ProfileCredentialsProvider.create("catalogue-developer")
)
.build()
case _ =>
secretsManagerClientBuilder.build()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ class ItemUpdateService(
// Construct a lookup from SourceIdentifier -> index
val updatedItemsWithIndex = itemsWithIndex
.map {
case (item, index) => getSrcId(item) -> index
case (item, index) =>
getSrcId(item) -> index
}
.flatMap {
// Add the correct index for an item by SourceIdentifier
Expand Down Expand Up @@ -71,7 +72,8 @@ class ItemUpdateService(
val items = work.items

val groupedItems = items.zipWithIndex.groupBy {
case (item, _) => getSrcId(item).map(_.identifierType.id)
case (item, _) =>
getSrcId(item).map(_.identifierType.id)
}

Future.sequence {
Expand All @@ -84,18 +86,19 @@ class ItemUpdateService(
preservedOrderItemsUpdate(
itemsWithIndex = itemsWithIndex,
updateFunction = updater.updateItems
)
)
))
.getOrElse(Future(itemsWithIndex))

case (None, itemsWithIndex) =>
Future(itemsWithIndex)
}
// unzipWithIndex
} map (_.flatten.toList.sortBy {
case (_, index) => index
case (_, index) =>
index
} map {
case (item, _) => item
case (item, _) =>
item
})
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,14 @@ import scala.concurrent.{ExecutionContext, Future}
* This provides an up to date view on whether a hold
* can be placed on an item, and generates a list of dates
* when the item can be viewed in the library
*
*/
class SierraItemUpdater(
sierraSource: SierraSource,
venuesOpeningTimesLookup: VenuesOpeningTimesLookup,
venueClock: Clock
)(
implicit executionContext: ExecutionContext
) extends ItemUpdater
)(implicit
executionContext: ExecutionContext)
extends ItemUpdater
with Logging
with DisplayItemOps {

Expand All @@ -45,7 +44,7 @@ class SierraItemUpdater(
): Future[Map[SierraItemNumber, SierraItemData]] =
sierraSource
.lookupItemEntries(staleItemIds)
.map(itemEither => {
.map { itemEither =>
val items = itemEither match {
case Right(SierraItemDataEntries(_, _, entries)) =>
entries.map(entry => entry.id -> Some(entry)) toMap
Expand All @@ -62,7 +61,7 @@ class SierraItemUpdater(
case (sierraItemNumber, Some(sierraItemData)) =>
sierraItemNumber -> sierraItemData
}
})
}

private def updateItem(
item: DisplayItem,
Expand Down Expand Up @@ -114,7 +113,9 @@ class SierraItemUpdater(
item: DisplayItem,
sierraItemLocation: Option[SierraLocation]
): Future[DisplayItem] =
if (item.physicalAccessCondition.exists(_.isRequestable) && sierraItemLocation.isDefined) {
if (item.physicalAccessCondition.exists(
_.isRequestable
) && sierraItemLocation.isDefined) {
val locationName = sierraItemLocation.get.code match {
case "harop" => "deepstore"
case _ => "library"
Expand Down Expand Up @@ -148,14 +149,9 @@ class SierraItemUpdater(
.flatMap(
venuesList =>
venuesList
.map(
venue =>
venue.title.toLowerCase() -> venue.openingTimes.map(
openingTime =>
AvailabilitySlot(openingTime.open, openingTime.close)
)
)
) toMap
.map(venue =>
venue.title.toLowerCase() -> venue.openingTimes.map(openingTime =>
AvailabilitySlot(openingTime.open, openingTime.close)))) toMap

private def libraryItemAvailabilities(
venuesOpeningTimes: Map[String, List[AvailabilitySlot]]
Expand Down Expand Up @@ -186,8 +182,7 @@ class SierraItemUpdater(
parseISOStringToLocalDate(openingTime.from)
.isAfter(
parseISOStringToLocalDate(firstDeepstoreAvailabilitySlot.from)
)
)
))
firstDeepstoreAvailabilitySlot :: subsequentLibraryAvailabilitySlots
}

Expand All @@ -213,5 +208,6 @@ class SierraItemUpdater(
private def parseISOStringToLocalDate(isoString: String): LocalDate =
LocalDate.parse(
isoString,
DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSSXXX"))
DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSSXXX")
)
}
2 changes: 1 addition & 1 deletion project/Common.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import sbt._

object Common {
val settings: Seq[Def.Setting[_]] = Seq(
scalaVersion := "2.12.16",
scalaVersion := "2.12.19",
organization := "weco",
resolvers ++= Seq(
"Wellcome releases" at "s3://releases.mvn-repo.wellcomecollection.org/"
Expand Down
Loading