def generateCollectionTemplates()

in app/services/editions/EditionsTemplating.scala [126:185]


  def generateCollectionTemplates(
      frontTemplate: FrontTemplate,
      edition: Edition,
      issueDate: LocalDate,
      editionTemplate: EditionTemplate,
      ophanQueryPrefillParams: Option[OphanQueryPrefillParams]
  ): List[EditionsCollectionSkeleton] = {
    val collections = frontTemplate.collections
    val maybeOphanPath = frontTemplate.maybeOphanPath
    collections.map { collectionTemplate =>
      import collectionTemplate.{hidden, name, prefill}

      val timeWindowConfig = List(
        collectionTemplate.maybeTimeWindowConfig,
        frontTemplate.maybeTimeWindowConfig
      )
        .collectFirst { case Some(timeWindowConfig) => timeWindowConfig }
        .getOrElse(editionTemplate.timeWindowConfig)

      val capiQueryTimeWindow: CapiQueryTimeWindow =
        timeWindowConfig.toCapiQueryTimeWindow(issueDate)

      val capiPrefillTimeParams = CapiPrefillTimeParams(
        capiQueryTimeWindow,
        editionTemplate.capiDateQueryParam
      )

      EditionsCollectionSkeleton(
        name,
        prefill
          .map { contentPrefillUrlSegments =>
            val prefillParams = PrefillParamsAdapter(
              issueDate,
              contentPrefillUrlSegments,
              capiPrefillTimeParams,
              List(
                collectionTemplate.maybeOphanPath,
                maybeOphanPath,
                editionTemplate.maybeOphanPath
              ).collectFirst { case Some(path) =>
                path
              }, // Get first non-None match,
              ophanQueryPrefillParams,
              edition,
              Some(collectionTemplate.cardCap),
              MetadataForLogging(
                issueDate,
                collectionId = None,
                collectionName = Some(name)
              )
            )
            getPrefillArticles(prefillParams)
          }
          .getOrElse(Nil),
        prefill,
        capiQueryTimeWindow,
        hidden
      )
    }
  }