Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move ArticleFormat Parsing Into DCAR #10543

Closed
wants to merge 1 commit into from

Conversation

JamieB-gu
Copy link
Contributor

Moves as much of the parsing of ArticleFormat as possible into DCAR, so we no longer have to rely on the CAPI client1 to do this. The current logic duplicates exactly what the CAPI client does2, so that we don't change too much at once. Improvements to the parsing logic can be made in a future change, once we've confirmed everything works as before.

At the moment, there isn't enough of the CAPI data available from frontend3 to fully parse ArticleFormat. Three further pieces of information are needed:

  1. Content type (content.type in CAPI)
  2. Display hint (content.fields.displayHint in CAPI)
  3. Whether a blog is currently live (content.fields.liveBloggingNow in CAPI)

In cases where these items are missing, the parsing logic falls back to the frontend definition of ArticleFormat. Once they are made available, in a future change, these fallbacks can be removed.

This change also renames format.ts to articleFormat.ts, to more closely resemble the name of the type.

Footnotes

  1. https://github.com/guardian/content-api-scala-client

  2. https://github.com/guardian/content-api-scala-client/blob/ea995d3282281029b9eaedd1e3566aebe6ac7300/client/src/main/scala/com.gu.contentapi.client/utils/CapiModelEnrichment.scala#L94

  3. https://github.com/guardian/dotcom-rendering/blob/89b180e31d73cc11d31e7562624bd46364e28f7b/dotcom-rendering/src/types/frontend.ts#L20

Copy link

github-actions bot commented Feb 9, 2024

Size Change: 0 B

Total Size: 767 kB

ℹ️ View Unchanged
Filename Size
dotcom-rendering/dist/1011.client.web.********************.js 3.14 kB
dotcom-rendering/dist/102.client.web.********************.js 5.09 kB
dotcom-rendering/dist/112.client.web.********************.js 822 B
dotcom-rendering/dist/1191.client.web.********************.js 680 B
dotcom-rendering/dist/1407.client.web.********************.js 640 B
dotcom-rendering/dist/1429.client.web.********************.js 17.9 kB
dotcom-rendering/dist/1459.client.web.********************.js 876 B
dotcom-rendering/dist/1519.client.web.********************.js 6.12 kB
dotcom-rendering/dist/1530.client.web.********************.js 8.55 kB
dotcom-rendering/dist/1541.client.web.********************.js 2.89 kB
dotcom-rendering/dist/1549.client.web.********************.js 4.81 kB
dotcom-rendering/dist/17.client.web.********************.js 1.85 kB
dotcom-rendering/dist/1749.client.web.********************.js 920 B
dotcom-rendering/dist/1827.client.web.********************.js 2.65 kB
dotcom-rendering/dist/1937.client.web.********************.js 2.43 kB
dotcom-rendering/dist/2293.client.web.********************.js 582 B
dotcom-rendering/dist/2337.client.web.********************.js 23 kB
dotcom-rendering/dist/2363.client.web.********************.js 5.75 kB
dotcom-rendering/dist/2364.client.web.********************.js 3.79 kB
dotcom-rendering/dist/2412.client.web.********************.js 3.67 kB
dotcom-rendering/dist/2443.client.web.********************.js 3 kB
dotcom-rendering/dist/3061.client.web.********************.js 3.06 kB
dotcom-rendering/dist/3170.client.web.********************.js 527 B
dotcom-rendering/dist/3235.client.web.********************.js 529 B
dotcom-rendering/dist/3375.client.web.********************.js 2.7 kB
dotcom-rendering/dist/351.client.web.********************.js 618 B
dotcom-rendering/dist/3671.client.web.********************.js 435 B
dotcom-rendering/dist/3737.client.web.********************.js 2.94 kB
dotcom-rendering/dist/393.client.web.********************.js 920 B
dotcom-rendering/dist/3936.client.web.********************.js 2.81 kB
dotcom-rendering/dist/397.client.web.********************.js 5.77 kB
dotcom-rendering/dist/3986.client.web.********************.js 495 B
dotcom-rendering/dist/4025.client.web.********************.js 39.9 kB
dotcom-rendering/dist/4040.client.web.********************.js 650 B
dotcom-rendering/dist/4045.client.web.********************.js 643 B
dotcom-rendering/dist/405.client.web.********************.js 914 B
dotcom-rendering/dist/4055.client.web.********************.js 3.2 kB
dotcom-rendering/dist/4269.client.web.********************.js 668 B
dotcom-rendering/dist/4390.client.web.********************.js 508 B
dotcom-rendering/dist/4438.client.web.********************.js 801 B
dotcom-rendering/dist/4442.client.web.********************.js 714 B
dotcom-rendering/dist/478.client.web.********************.js 595 B
dotcom-rendering/dist/4870.client.web.********************.js 748 B
dotcom-rendering/dist/4911.client.web.********************.js 780 B
dotcom-rendering/dist/5020.client.web.********************.js 994 B
dotcom-rendering/dist/5047.client.web.********************.js 779 B
dotcom-rendering/dist/5055.client.web.********************.js 4.6 kB
dotcom-rendering/dist/5196.client.web.********************.js 13.2 kB
dotcom-rendering/dist/5569.client.web.********************.js 3.56 kB
dotcom-rendering/dist/5619.client.web.********************.js 926 B
dotcom-rendering/dist/5730.client.web.********************.js 954 B
dotcom-rendering/dist/5898.client.web.********************.js 4.33 kB
dotcom-rendering/dist/5985.client.web.********************.js 750 B
dotcom-rendering/dist/6043.client.web.********************.js 852 B
dotcom-rendering/dist/6140.client.web.********************.js 853 B
dotcom-rendering/dist/6302.client.web.********************.js 2.68 kB
dotcom-rendering/dist/6351.client.web.********************.js 3.42 kB
dotcom-rendering/dist/6651.client.web.********************.js 904 B
dotcom-rendering/dist/6693.client.web.********************.js 822 B
dotcom-rendering/dist/6847.client.web.********************.js 4.85 kB
dotcom-rendering/dist/6853.client.web.********************.js 1 kB
dotcom-rendering/dist/6981.client.web.********************.js 3.87 kB
dotcom-rendering/dist/7018.client.web.********************.js 787 B
dotcom-rendering/dist/7024.client.web.********************.js 3.6 kB
dotcom-rendering/dist/7324.client.web.********************.js 3.49 kB
dotcom-rendering/dist/7356.client.web.********************.js 1 kB
dotcom-rendering/dist/764.client.web.********************.js 6.02 kB
dotcom-rendering/dist/7855.client.web.********************.js 788 B
dotcom-rendering/dist/8002.client.web.********************.js 801 B
dotcom-rendering/dist/8030.client.web.********************.js 3.77 kB
dotcom-rendering/dist/8166.client.web.********************.js 1.56 kB
dotcom-rendering/dist/8288.client.web.********************.js 23 kB
dotcom-rendering/dist/841.client.web.********************.js 789 B
dotcom-rendering/dist/8695.client.web.********************.js 8.67 kB
dotcom-rendering/dist/8749.client.web.********************.js 3.24 kB
dotcom-rendering/dist/8818.client.web.********************.js 748 B
dotcom-rendering/dist/8937.client.web.********************.js 888 B
dotcom-rendering/dist/898.client.web.********************.js 3.74 kB
dotcom-rendering/dist/9140.client.web.********************.js 8.28 kB
dotcom-rendering/dist/9173.client.web.********************.js 723 B
dotcom-rendering/dist/9314.client.web.********************.js 822 B
dotcom-rendering/dist/9328.client.web.********************.js 3.53 kB
dotcom-rendering/dist/9605.client.web.********************.js 4.79 kB
dotcom-rendering/dist/9621.client.web.********************.js 723 B
dotcom-rendering/dist/9676.client.web.********************.js 889 B
dotcom-rendering/dist/9727.client.web.********************.js 5.89 kB
dotcom-rendering/dist/9886.client.web.********************.js 9.99 kB
dotcom-rendering/dist/9933.client.web.********************.js 5.1 kB
dotcom-rendering/dist/9978.client.web.********************.js 960 B
dotcom-rendering/dist/AdPortals-importable.client.web.********************.js 3.72 kB
dotcom-rendering/dist/AlreadyVisited-importable.client.web.********************.js 424 B
dotcom-rendering/dist/AppsEpic-importable.client.web.********************.js 4.12 kB
dotcom-rendering/dist/AppsFooter-importable.client.web.********************.js 3.62 kB
dotcom-rendering/dist/AppsLightboxImage-importable.client.web.********************.js 3 kB
dotcom-rendering/dist/AppsLightboxImageStore-importable.client.web.********************.js 2.42 kB
dotcom-rendering/dist/AudioAtomWrapper-importable.client.web.********************.js 3.63 kB
dotcom-rendering/dist/AustralianTerritorySwitcher-importable.client.web.********************.js 2.03 kB
dotcom-rendering/dist/Branding-importable.client.web.********************.js 2.65 kB
dotcom-rendering/dist/braze-web-sdk-core.client.web.********************.js 36.9 kB
dotcom-rendering/dist/BrazeMessaging-importable.client.web.********************.js 5.29 kB
dotcom-rendering/dist/CalloutBlockComponent-importable.client.web.********************.js 6.78 kB
dotcom-rendering/dist/CalloutEmbedBlockComponent-importable.client.web.********************.js 5.78 kB
dotcom-rendering/dist/CardCommentCount-importable.client.web.********************.js 4.85 kB
dotcom-rendering/dist/Carousel-importable.client.web.********************.js 5.56 kB
dotcom-rendering/dist/CarouselForNewsletters-importable.client.web.********************.js 5.66 kB
dotcom-rendering/dist/ChartAtom-importable.client.web.********************.js 538 B
dotcom-rendering/dist/CommentCount-importable.client.web.********************.js 3.29 kB
dotcom-rendering/dist/DiscussionApps-importable.client.web.********************.js 859 B
dotcom-rendering/dist/DiscussionMeta-importable.client.web.********************.js 4.06 kB
dotcom-rendering/dist/DiscussionWeb-importable.client.web.********************.js 1.67 kB
dotcom-rendering/dist/DocumentBlockComponent-importable.client.web.********************.js 3.61 kB
dotcom-rendering/dist/EmbedBlockComponent-importable.client.web.********************.js 4.16 kB
dotcom-rendering/dist/EnhancePinnedPost-importable.client.web.********************.js 2.01 kB
dotcom-rendering/dist/FetchOnwardsData-importable.client.web.********************.js 2.55 kB
dotcom-rendering/dist/FilterKeyEventsToggle-importable.client.web.********************.js 3.35 kB
dotcom-rendering/dist/FocusStyles-importable.client.web.********************.js 611 B
dotcom-rendering/dist/FollowWrapper-importable.client.web.********************.js 841 B
dotcom-rendering/dist/FooterLabel-importable.client.web.********************.js 342 B
dotcom-rendering/dist/frameworks.client.web.********************.js 20.7 kB
dotcom-rendering/dist/GetCricketScoreboard-importable.client.web.********************.js 3.82 kB
dotcom-rendering/dist/GetMatchNav-importable.client.web.********************.js 10.8 kB
dotcom-rendering/dist/GetMatchStats-importable.client.web.********************.js 1.68 kB
dotcom-rendering/dist/GetMatchTabs-importable.client.web.********************.js 2.67 kB
dotcom-rendering/dist/guardian-braze-components-banner.client.web.********************.js 14.8 kB
dotcom-rendering/dist/guardian-braze-components-end-of-article.client.web.********************.js 9.32 kB
dotcom-rendering/dist/GuideAtomWrapper-importable.client.web.********************.js 780 B
dotcom-rendering/dist/HeaderTopBar-importable.client.web.********************.js 10.9 kB
dotcom-rendering/dist/index.client.web.********************.js 47.5 kB
dotcom-rendering/dist/InstagramBlockComponent-importable.client.web.********************.js 3.7 kB
dotcom-rendering/dist/InteractiveAtomMessenger-importable.client.web.********************.js 855 B
dotcom-rendering/dist/InteractiveBlockComponent-importable.client.web.********************.js 6.09 kB
dotcom-rendering/dist/InteractiveContentsBlockComponent-importable.client.web.********************.js 4.72 kB
dotcom-rendering/dist/InteractiveSupportButton-importable.client.web.********************.js 3.49 kB
dotcom-rendering/dist/KeyEventsCarousel-importable.client.web.********************.js 4.59 kB
dotcom-rendering/dist/KnowledgeQuizAtom-importable.client.web.********************.js 3.54 kB
dotcom-rendering/dist/LatestLinks-importable.client.web.********************.js 2.22 kB
dotcom-rendering/dist/LightboxHash-importable.client.web.********************.js 434 B
dotcom-rendering/dist/LightboxLayout-importable.client.web.********************.js 6.46 kB
dotcom-rendering/dist/LiveBlogEpic-importable.client.web.********************.js 3.6 kB
dotcom-rendering/dist/Liveness-importable.client.web.********************.js 4.95 kB
dotcom-rendering/dist/ManyNewsletterSignUp-importable.client.web.********************.js 6.63 kB
dotcom-rendering/dist/MapEmbedBlockComponent-importable.client.web.********************.js 5.69 kB
dotcom-rendering/dist/Metrics-importable.client.web.********************.js 2.29 kB
dotcom-rendering/dist/MostViewedFooter-importable.client.web.********************.js 4.04 kB
dotcom-rendering/dist/MostViewedFooterData-importable.client.web.********************.js 6.73 kB
dotcom-rendering/dist/MostViewedRightWrapper-importable.client.web.********************.js 4.44 kB
dotcom-rendering/dist/OnwardsUpper-importable.client.web.********************.js 4.29 kB
dotcom-rendering/dist/PersonalityQuizAtom-importable.client.web.********************.js 3.66 kB
dotcom-rendering/dist/ProfileAtom-importable.client.web.********************.js 542 B
dotcom-rendering/dist/ProfileAtomWrapper-importable.client.web.********************.js 800 B
dotcom-rendering/dist/PulsingDot-importable.client.web.********************.js 749 B
dotcom-rendering/dist/QandaAtom-importable.client.web.********************.js 537 B
dotcom-rendering/dist/ReaderRevenueDev-importable.client.web.********************.js 469 B
dotcom-rendering/dist/readerRevenueDevUtils.client.web.********************.js 1.9 kB
dotcom-rendering/dist/ReaderRevenueLinks-importable.client.web.********************.js 5.78 kB
dotcom-rendering/dist/RelativeTime-importable.client.web.********************.js 1.99 kB
dotcom-rendering/dist/RichLinkComponent-importable.client.web.********************.js 6.25 kB
dotcom-rendering/dist/SecureSignup-importable.client.web.********************.js 3.63 kB
dotcom-rendering/dist/SendAMessage-importable.client.web.********************.js 4.43 kB
dotcom-rendering/dist/SendTargetingParams-importable.client.web.********************.js 2.11 kB
dotcom-rendering/dist/sentry.client.web.********************.js 786 B
dotcom-rendering/dist/SetABTests-importable.client.web.********************.js 3.42 kB
dotcom-rendering/dist/SetAdTargeting-importable.client.web.********************.js 485 B
dotcom-rendering/dist/ShareButton-importable.client.web.********************.js 2.42 kB
dotcom-rendering/dist/shimport.client.web.********************.js 2.79 kB
dotcom-rendering/dist/ShowHideContainers-importable.client.web.********************.js 647 B
dotcom-rendering/dist/ShowMore-importable.client.web.********************.js 5.71 kB
dotcom-rendering/dist/SignInGateMain.client.web.********************.js 3.93 kB
dotcom-rendering/dist/SignInGateMainCheckoutComplete.client.web.********************.js 5.04 kB
dotcom-rendering/dist/SignInGateSelector-importable.client.web.********************.js 5.64 kB
dotcom-rendering/dist/SlotBodyEnd-importable.client.web.********************.js 6.84 kB
dotcom-rendering/dist/SpotifyBlockComponent-importable.client.web.********************.js 5.53 kB
dotcom-rendering/dist/StickyBottomBanner-importable.client.web.********************.js 5.38 kB
dotcom-rendering/dist/SubNav-importable.client.web.********************.js 2.25 kB
dotcom-rendering/dist/SupportTheG-importable.client.web.********************.js 5.91 kB
dotcom-rendering/dist/TableOfContents-importable.client.web.********************.js 3.17 kB
dotcom-rendering/dist/TimelineAtom-importable.client.web.********************.js 1.24 kB
dotcom-rendering/dist/TweetBlockComponent-importable.client.web.********************.js 1.02 kB
dotcom-rendering/dist/UnsafeEmbedBlockComponent-importable.client.web.********************.js 3.71 kB
dotcom-rendering/dist/VideoFacebookBlockComponent-importable.client.web.********************.js 5.7 kB
dotcom-rendering/dist/VineBlockComponent-importable.client.web.********************.js 3.54 kB
dotcom-rendering/dist/WeatherWrapper-importable.client.web.********************.js 5.47 kB
dotcom-rendering/dist/YoutubeBlockComponent-importable.client.web.********************.js 3.97 kB

compressed-size-action

@JamieB-gu JamieB-gu marked this pull request as ready for review February 12, 2024 16:53
@JamieB-gu JamieB-gu requested a review from a team as a code owner February 12, 2024 16:53
@JamieB-gu JamieB-gu added the run_chromatic Runs chromatic when label is applied label Feb 12, 2024
Copy link

Hello 👋! When you're ready to run Chromatic, please apply the run_chromatic label to this PR.

Click here to see the Chromatic project.

Copy link
Contributor

@mxdvl mxdvl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes!

This makes me wonder why the article types live in @guardian/libs

@JamieB-gu
Copy link
Contributor Author

This makes me wonder why the article types live in @guardian/libs

For now because ArticleFormat is used by AR and some of the components in Source.

Copy link
Contributor

@cemms1 cemms1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👏

@OllysCoding
Copy link
Contributor

❤️

Moves as much of the parsing of `ArticleFormat` as possible into DCAR, so we no longer have to rely on the CAPI client to do this. The current logic duplicates exactly what the CAPI client does, so that we don't change too much at once. Improvements to the parsing logic can be made in a future change, once we've confirmed everything works as before.

At the moment, there isn't enough of the CAPI data available from frontend to fully parse `ArticleFormat`. Three further pieces of information are needed:

1. Content type (`content.type` in CAPI)
2. Display hint (`content.fields.displayHint` in CAPI)
3. Whether a blog is currently live (`content.fields.liveBloggingNow` in CAPI)

In cases where these items are missing, the parsing logic falls back to the frontend definition of `ArticleFormat`. Once they are made available, in a future change, these fallbacks can be removed.

This change also renames `format.ts` to `articleFormat.ts`, to more closely resemble the name of the type.
@JamieB-gu JamieB-gu force-pushed the move-format-parsing-into-dcar branch from fcdbf24 to 54f4ae3 Compare February 21, 2024 14:23
@JamieB-gu JamieB-gu marked this pull request as draft February 22, 2024 13:57
Copy link

"This PR is stale because it has been open 30 days with no activity. Unless a comment is added or the “stale” label removed, this will be closed in 3 days"

@github-actions github-actions bot added the Stale label Mar 24, 2024
Copy link

This PR was closed because it has been stalled for 3 days with no activity.

@github-actions github-actions bot closed this Mar 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dotcom-rendering run_chromatic Runs chromatic when label is applied Stale
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants