Skip to content

Commit

Permalink
Add Apps as a format in the render match
Browse files Browse the repository at this point in the history
  • Loading branch information
abeddow91 committed Oct 11, 2023
1 parent 203d482 commit e71f595
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
9 changes: 7 additions & 2 deletions applications/app/controllers/InteractiveController.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import common._
import conf.Configuration.interactive.cdnPath
import conf.switches.Switches
import contentapi.ContentApiClient
import implicits.{AmpFormat, HtmlFormat, JsonFormat}
import implicits.{AmpFormat, AppsFormat, HtmlFormat, JsonFormat}
import model.Cached.{RevalidatableResult, WithoutRevalidationResult}
import model.{InteractivePage, _}
import model.content.InteractiveAtom
Expand Down Expand Up @@ -112,6 +112,11 @@ class InteractiveController(
remoteRenderer.getAMPInteractive(wsClient, page, blocks, pageType)
}

def renderApps(page: InteractivePage, blocks: Blocks)(implicit request: RequestHeader): Future[Result] = {
val pageType = PageType.apply(page, request, context)
remoteRenderer.getAppsInteractive(wsClient, page, blocks, pageType)
}

override def renderItem(path: String)(implicit request: RequestHeader): Future[Result] = {
val requestFormat = request.getRequestFormat
val isUSElectionAMP = USElection2020AmpPages.pathIsSpecialHanding(path) && requestFormat == AmpFormat
Expand All @@ -120,8 +125,8 @@ class InteractiveController(
model match {
case Right((page, blocks)) => {
val tier = InteractivePicker.getRenderingTier(path)

(requestFormat, tier) match {
case (AppsFormat, DotcomRendering) => renderApps(page, blocks)
case (AmpFormat, DotcomRendering) => renderAmp(page, blocks)
case (JsonFormat, DotcomRendering) => renderJson(page, blocks)
case (HtmlFormat, PressedInteractive) => servePressedPage(path)
Expand Down
16 changes: 16 additions & 0 deletions common/app/renderers/DotcomRenderingService.scala
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,22 @@ class DotcomRenderingService extends GuLogging with ResultWithPreconnectPreload
post(ws, json, Configuration.rendering.baseURL + "/AMPInteractive", page.metadata.cacheTime)
}

def getAppsInteractive(
ws: WSClient,
page: InteractivePage,
blocks: Blocks,
pageType: PageType,
)(implicit request: RequestHeader): Future[Result] = {

val dataModel = DotcomRenderingDataModel.forInteractive(page, blocks, request, pageType)
val json = DotcomRenderingDataModel.toJson(dataModel)

// Nb. interactives have a longer timeout because some of them are very
// large unfortunately. E.g.
// https://www.theguardian.com/education/ng-interactive/2018/may/29/university-guide-2019-league-table-for-computer-science-information.
post(ws, json, Configuration.rendering.baseURL + "/AppsInteractive", page.metadata.cacheTime, 4.seconds)
}

def getEmailNewsletters(
ws: WSClient,
newsletters: List[NewsletterResponseV2],
Expand Down

0 comments on commit e71f595

Please sign in to comment.