Skip to content

Commit

Permalink
scalafmt
Browse files Browse the repository at this point in the history
  • Loading branch information
Georges-GNM committed Jan 8, 2025
1 parent 5633883 commit c2c0ed1
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 8 deletions.
6 changes: 5 additions & 1 deletion app/controllers/StoriesVisibleController.scala
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@ class StoriesVisibleController(
def storiesVisible(containerType: String) =
AccessAPIAuthAction(parse.json[StoriesVisibleRequest]) { implicit request =>
val storiesVisible =
containerService.getStoriesVisible(containerType, request.body.stories, collectionConfigJson = null)
containerService.getStoriesVisible(
containerType,
request.body.stories,
collectionConfigJson = null
)

logger.info(
s"got stories-visible=$storiesVisible for containerType=$containerType"
Expand Down
2 changes: 1 addition & 1 deletion app/services/CollectionService.scala
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ object CollectionService {
config: ConfigJson,
containerService: ContainerService
): Option[StoriesVisibleByStage] = {
val cConfigJson = config.collections.get(collectionId).get
val cConfigJson = config.collections.get(collectionId).get
val stages =
CollectionService.getStoriesForCollectionStages(collectionId, collection)
config.collections.get(collectionId).flatMap(_.`type`) match {
Expand Down
11 changes: 9 additions & 2 deletions app/services/ContainerService.scala
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@ object StoriesVisibleResponse {
}

class ContainerService(val containers: Containers) {
def getStoriesVisible(containerType: String, stories: Seq[Story], collectionConfigJson: CollectionConfigJson) = {
def getStoriesVisible(
containerType: String,
stories: Seq[Story],
collectionConfigJson: CollectionConfigJson
) = {
val numberOfStories = stories.length
containers.all.get(containerType) map {
case Fixed(container) =>
Expand Down Expand Up @@ -49,7 +53,10 @@ class ContainerService(val containers: Containers) {
)

case Flexible(container) =>
val numberVisible = container.storiesVisible(stories, collectionConfigJson: CollectionConfigJson)
val numberVisible = container.storiesVisible(
stories,
collectionConfigJson: CollectionConfigJson
)
StoriesVisibleResponse(
Some(numberVisible),
Some(numberVisible)
Expand Down
17 changes: 13 additions & 4 deletions app/slices/FlexibleContainer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,24 @@ package slices
import com.gu.facia.client.models.CollectionConfigJson

trait FlexibleContainer {
def storiesVisible(stories: Seq[Story], collectionConfigJson: CollectionConfigJson): Int
def storiesVisible(
stories: Seq[Story],
collectionConfigJson: CollectionConfigJson
): Int
}

object FlexibleGeneral extends FlexibleContainer {
def storiesVisible(stories: Seq[Story], collectionConfigJson: CollectionConfigJson): Int = {
def storiesVisible(
stories: Seq[Story],
collectionConfigJson: CollectionConfigJson
): Int = {
val byGroup = Story.segmentByGroup(stories)
val splash = byGroup.getOrElse(3, Seq.empty) ++
byGroup.getOrElse(2, Seq.empty) ++
byGroup.getOrElse(1, Seq.empty)
val numOfSplash = splash.size min 1
val numOfStandard = stories.size - numOfSplash
val defaultStandardStoryLimit = 8
val defaultStandardStoryLimit = 8

val standardStoryLimit = collectionConfigJson.displayHints
.flatMap(_.maxItemsToDisplay)
Expand All @@ -24,7 +30,10 @@ object FlexibleGeneral extends FlexibleContainer {
}

object FlexibleSpecial extends FlexibleContainer {
def storiesVisible(stories: Seq[Story], collectionConfigJson: CollectionConfigJson): Int = {
def storiesVisible(
stories: Seq[Story],
collectionConfigJson: CollectionConfigJson
): Int = {
val byGroup = Story.segmentByGroup(stories)
val snap = byGroup.getOrElse(3, Seq.empty) ++
byGroup.getOrElse(2, Seq.empty) ++
Expand Down

0 comments on commit c2c0ed1

Please sign in to comment.