in app/data/AtomListStore.scala [18:48]
override def getAtoms(search: Option[String], limit: Option[Int], shouldUseCreatedDateForSort: Boolean): MediaAtomList = {
// CAPI max page size is 200
val cappedLimit: Option[Int] = limit.map(Math.min(200, _))
val base: Map[String, String] = Map(
"types" -> "media",
"order-by" -> "newest"
) ++ (if(shouldUseCreatedDateForSort) Map("order-date" -> "first-publication") else Map.empty)
val baseWithSearch = search match {
case Some(q) => base ++ Map(
"q" -> q,
"searchFields" -> "title"
)
case None => base
}
val baseWithSearchAndLimit = cappedLimit match {
case Some(pageSize) => baseWithSearch ++ Map(
"page-size" -> pageSize.toString
)
case None => baseWithSearch
}
val response = capi.capiQuery("atoms", baseWithSearchAndLimit)
val total = (response \ "response" \ "total").as[Int]
val results = (response \ "response" \ "results").as[JsArray]
MediaAtomList(total, results.value.flatMap(fromJson).toList)
}