Skip to content

Commit

Permalink
Adjust collection level logic to default to Primary for beta collecti…
Browse files Browse the repository at this point in the history
…ons (#27607)


Co-authored-by: Charlotte Emms <[email protected]>
  • Loading branch information
Georges-GNM and cemms1 authored Nov 20, 2024
1 parent d4d763a commit c7b403b
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 8 deletions.
28 changes: 21 additions & 7 deletions common/app/model/CollectionConfig.scala
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package model.pressed

import com.gu.facia.api.{models => fapi}
import com.gu.facia.client.models.{Backfill, CollectionConfigJson, Metadata, CollectionPlatform, Primary, Secondary}
import com.gu.facia.client.models.{Backfill, CollectionConfigJson, Metadata, CollectionPlatform, Secondary}

final case class CollectionConfig(
displayName: Option[String],
Expand Down Expand Up @@ -29,14 +29,28 @@ object CollectionConfig {

def make(config: fapi.CollectionConfig): CollectionConfig = {

/** Extract `primary` or `secondary` collection level tag from metadata if present. Collection level is a concept
* that allows the platforms to style containers differently based on their "level"
val betaCollections = List(
"flexible/special",
"flexible/general",
"scrollable/highlights",
"scrollable/small",
"scrollable/medium",
"scrollable/feature",
"static/medium/4",
"static/feature/2",
)

/** Collection level is a concept that allows the platforms to style containers differently based on their "level".
* Beta collections are "Secondary" if tagged as such or "Primary" otherwise. Legacy containers have no container
* level set.
*/
val collectionLevel: Option[String] = config.metadata.flatMap { metadataList =>
metadataList.collectFirst {
case Primary => "Primary"
case Secondary => "Secondary"
val collectionLevel: Option[String] = if (betaCollections.contains(config.collectionType)) {
config.metadata.getOrElse(List.empty).find(_ == Secondary) match {
case Some(_) => Some("Secondary")
case None => Some("Primary")
}
} else {
None
}

CollectionConfig(
Expand Down
2 changes: 1 addition & 1 deletion project/Dependencies.scala
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ object Dependencies {
val awsVersion = "1.12.758"
val awsSdk2Version = "2.26.27"
val capiVersion = "32.0.0"
val faciaVersion = "12.1.0"
val faciaVersion = "13.0.0"
val dispatchVersion = "0.13.1"
val romeVersion = "1.0"
val jerseyVersion = "1.19.4"
Expand Down

0 comments on commit c7b403b

Please sign in to comment.