diff --git a/applications/app/controllers/InteractiveController.scala b/applications/app/controllers/InteractiveController.scala index a0bff41fd2d..86010cf512e 100644 --- a/applications/app/controllers/InteractiveController.scala +++ b/applications/app/controllers/InteractiveController.scala @@ -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 @@ -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 @@ -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) diff --git a/common/app/renderers/DotcomRenderingService.scala b/common/app/renderers/DotcomRenderingService.scala index 1067eaa023c..fe905faa016 100644 --- a/common/app/renderers/DotcomRenderingService.scala +++ b/common/app/renderers/DotcomRenderingService.scala @@ -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],