in app/services/editions/db/CollectionsQueries.scala [53:115]
def getCollectionPrefill(id: String) = DB readOnly { implicit session =>
val rows =
sql"""
SELECT collections.prefill,
collections.path_type,
collections.content_prefill_window_start,
collections.content_prefill_window_end,
cards.id,
edition_issues.name,
edition_issues.issue_date,
edition_issues.timezone_id
FROM collections
LEFT JOIN cards ON (collections.id = cards.collection_id)
JOIN fronts ON (collections.front_id = fronts.id)
JOIN edition_issues ON (fronts.issue_id = edition_issues.id)
WHERE collections.id = $id
"""
.map { rs =>
val date = rs.localDate("issue_date")
val editionStr = rs.string("name")
val edition = Edition.withName(editionStr)
val zone = ZoneId.of(rs.string("timezone_id"))
val pathTypeStr = rs.string("path_type")
val pathType = PathType.withName(pathTypeStr)
val timeWinStart =
rs.zonedDateTime("content_prefill_window_start").toInstant
val timeWinEnd =
rs.zonedDateTime("content_prefill_window_end").toInstant
val contentPrefillQueryTimeWindow =
CapiQueryTimeWindow(timeWinStart, timeWinEnd)
(
date,
edition,
zone,
CapiPrefillQuery(rs.string("prefill"), pathType),
contentPrefillQueryTimeWindow,
rs.string("id")
)
}
.list
.apply()
rows.headOption.map {
case (
issueDate,
edition,
zone,
prefillQueryUrlSegments,
contentPrefillQueryTimeWindow,
_
) =>
PrefillUpdate(
issueDate,
edition,
zone,
prefillQueryUrlSegments,
contentPrefillQueryTimeWindow,
rows.map(_._6)
)
}
}