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

Add A Model For Timeline Elements #11011

Merged
merged 3 commits into from
Mar 28, 2024
Merged

Add A Model For Timeline Elements #11011

merged 3 commits into from
Mar 28, 2024

Conversation

JamieB-gu
Copy link
Contributor

@JamieB-gu JamieB-gu commented Mar 25, 2024

First, renamed the TimelineEvent type used by timeline atoms to TimelineAtomEvent to avoid confusion.

Then removed the now-unused TimelineBlockElement and replaced it with FETimelineBlockElement, to represent the new element coming from frontend, and DCRTimelineBlockElement, to represent the parsed/enhanced version in DCR. The DCR version is stricter than the one coming from frontend, enforcing the following rules:

  • Timeline events must have a date
  • Timeline sections must have a title
  • Timelines with one section should be flattened into a single list of events

Finally, added an enhancer module for timelines to convert from the frontend type to the DCR one.

Part of #10869. See guardian/content-api-models#245 for the proposed CAPI model.

First, renamed the `TimelineEvent` type used by timeline atoms to `TimelineAtomEvent` to avoid confusion.

Then removed the now-unused `TimelineBlockElement` and replaced it with `FETimelineBlockElement`, to represent the new element coming from frontend, and `DCRTimelineBlockElement`, to represent the parsed/enhanced version in DCR. The DCR version is stricter than the one coming from frontend, enforcing the following rules:

- Timeline events must have a date
- Timeline sections must have a title
- Timelines with one section should be flattened into a single list of events

Finally, added an enhancer module for timelines to convert from the frontend type to the DCR one.
@JamieB-gu JamieB-gu added this to the Article Structure milestone Mar 25, 2024
@JamieB-gu JamieB-gu self-assigned this Mar 25, 2024
@JamieB-gu JamieB-gu requested a review from a team as a code owner March 25, 2024 13:48
Copy link

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

You will need to reapply the label each time you want to run Chromatic.

Click here to see the Chromatic project.

Copy link

github-actions bot commented Mar 25, 2024

Size Change: +371 B (0%)

Total Size: 762 kB

Filename Size Change
dotcom-rendering/dist/5346.client.web.********************.js 23.2 kB -159 B (-1%)
dotcom-rendering/dist/LiveBlogEpic-importable.client.web.********************.js 3.85 kB +178 B (+5%) 🔍
dotcom-rendering/dist/SetABTests-importable.client.web.********************.js 3.94 kB +136 B (+4%)
dotcom-rendering/dist/StickyBottomBanner-importable.client.web.********************.js 3.94 kB +127 B (+3%)
ℹ️ View Unchanged
Filename Size Change
dotcom-rendering/dist/1225.client.web.********************.js 781 B 0 B
dotcom-rendering/dist/1299.client.web.********************.js 926 B 0 B
dotcom-rendering/dist/134.client.web.********************.js 528 B 0 B
dotcom-rendering/dist/1420.client.web.********************.js 3.77 kB 0 B
dotcom-rendering/dist/15.client.web.********************.js 3.68 kB 0 B
dotcom-rendering/dist/1647.client.web.********************.js 2.93 kB 0 B
dotcom-rendering/dist/2122.client.web.********************.js 3.41 kB 0 B
dotcom-rendering/dist/2253.client.web.********************.js 10.2 kB 0 B
dotcom-rendering/dist/23.client.web.********************.js 2.54 kB 0 B
dotcom-rendering/dist/2342.client.web.********************.js 1 kB 0 B
dotcom-rendering/dist/2471.client.web.********************.js 715 B 0 B
dotcom-rendering/dist/2778.client.web.********************.js 853 B 0 B
dotcom-rendering/dist/2797.client.web.********************.js 4.81 kB 0 B
dotcom-rendering/dist/3000.client.web.********************.js 887 B 0 B
dotcom-rendering/dist/3035.client.web.********************.js 2.88 kB 0 B
dotcom-rendering/dist/309.client.web.********************.js 3.86 kB 0 B
dotcom-rendering/dist/3114.client.web.********************.js 651 B 0 B
dotcom-rendering/dist/3118.client.web.********************.js 496 B 0 B
dotcom-rendering/dist/3255.client.web.********************.js 803 B 0 B
dotcom-rendering/dist/3303.client.web.********************.js 6.01 kB 0 B
dotcom-rendering/dist/3325.client.web.********************.js 3.14 kB 0 B
dotcom-rendering/dist/3336.client.web.********************.js 781 B 0 B
dotcom-rendering/dist/3364.client.web.********************.js 4.77 kB 0 B
dotcom-rendering/dist/3368.client.web.********************.js 3.75 kB 0 B
dotcom-rendering/dist/3494.client.web.********************.js 823 B 0 B
dotcom-rendering/dist/3503.client.web.********************.js 438 B 0 B
dotcom-rendering/dist/3514.client.web.********************.js 3.19 kB 0 B
dotcom-rendering/dist/3642.client.web.********************.js 787 B 0 B
dotcom-rendering/dist/3922.client.web.********************.js 724 B 0 B
dotcom-rendering/dist/3932.client.web.********************.js 789 B 0 B
dotcom-rendering/dist/4164.client.web.********************.js 3.56 kB 0 B
dotcom-rendering/dist/424.client.web.********************.js 749 B 0 B
dotcom-rendering/dist/4248.client.web.********************.js 3.81 kB 0 B
dotcom-rendering/dist/4367.client.web.********************.js 3.42 kB 0 B
dotcom-rendering/dist/4401.client.web.********************.js 8.68 kB +19 B (0%)
dotcom-rendering/dist/4442.client.web.********************.js 823 B 0 B
dotcom-rendering/dist/4673.client.web.********************.js 723 B 0 B
dotcom-rendering/dist/4811.client.web.********************.js 994 B 0 B
dotcom-rendering/dist/5044.client.web.********************.js 802 B 0 B
dotcom-rendering/dist/5084.client.web.********************.js 751 B 0 B
dotcom-rendering/dist/516.client.web.********************.js 5.86 kB 0 B
dotcom-rendering/dist/5291.client.web.********************.js 2.65 kB 0 B
dotcom-rendering/dist/5308.client.web.********************.js 2.7 kB 0 B
dotcom-rendering/dist/5417.client.web.********************.js 3.49 kB 0 B
dotcom-rendering/dist/565.client.web.********************.js 669 B 0 B
dotcom-rendering/dist/5786.client.web.********************.js 1.85 kB 0 B
dotcom-rendering/dist/5817.client.web.********************.js 915 B 0 B
dotcom-rendering/dist/5874.client.web.********************.js 2.42 kB 0 B
dotcom-rendering/dist/6049.client.web.********************.js 3 kB 0 B
dotcom-rendering/dist/6093.client.web.********************.js 749 B 0 B
dotcom-rendering/dist/6167.client.web.********************.js 640 B 0 B
dotcom-rendering/dist/6405.client.web.********************.js 3.14 kB 0 B
dotcom-rendering/dist/6640.client.web.********************.js 906 B 0 B
dotcom-rendering/dist/676.client.web.********************.js 3.87 kB 0 B
dotcom-rendering/dist/6792.client.web.********************.js 3.34 kB 0 B
dotcom-rendering/dist/6871.client.web.********************.js 4.85 kB 0 B
dotcom-rendering/dist/7116.client.web.********************.js 23 kB 0 B
dotcom-rendering/dist/7196.client.web.********************.js 889 B 0 B
dotcom-rendering/dist/72.client.web.********************.js 961 B 0 B
dotcom-rendering/dist/7310.client.web.********************.js 2.95 kB 0 B
dotcom-rendering/dist/7387.client.web.********************.js 955 B 0 B
dotcom-rendering/dist/7522.client.web.********************.js 4.19 kB 0 B
dotcom-rendering/dist/7702.client.web.********************.js 527 B 0 B
dotcom-rendering/dist/7723.client.web.********************.js 921 B 0 B
dotcom-rendering/dist/7799.client.web.********************.js 5.75 kB 0 B
dotcom-rendering/dist/7951.client.web.********************.js 2.67 kB 0 B
dotcom-rendering/dist/8134.client.web.********************.js 595 B 0 B
dotcom-rendering/dist/8135.client.web.********************.js 4.59 kB 0 B
dotcom-rendering/dist/8179.client.web.********************.js 825 B 0 B
dotcom-rendering/dist/8565.client.web.********************.js 642 B 0 B
dotcom-rendering/dist/8606.client.web.********************.js 1.56 kB 0 B
dotcom-rendering/dist/8678.client.web.********************.js 5.9 kB 0 B
dotcom-rendering/dist/8699.client.web.********************.js 619 B 0 B
dotcom-rendering/dist/877.client.web.********************.js 17.9 kB 0 B
dotcom-rendering/dist/8776.client.web.********************.js 2.98 kB 0 B
dotcom-rendering/dist/8791.client.web.********************.js 1 kB 0 B
dotcom-rendering/dist/8824.client.web.********************.js 8.6 kB 0 B
dotcom-rendering/dist/8861.client.web.********************.js 2.81 kB 0 B
dotcom-rendering/dist/889.client.web.********************.js 854 B 0 B
dotcom-rendering/dist/8907.client.web.********************.js 789 B 0 B
dotcom-rendering/dist/8995.client.web.********************.js 3.6 kB 0 B
dotcom-rendering/dist/9060.client.web.********************.js 877 B 0 B
dotcom-rendering/dist/9068.client.web.********************.js 3.46 kB 0 B
dotcom-rendering/dist/9107.client.web.********************.js 41.7 kB 0 B
dotcom-rendering/dist/9157.client.web.********************.js 8.3 kB +1 B (0%)
dotcom-rendering/dist/9225.client.web.********************.js 582 B 0 B
dotcom-rendering/dist/9359.client.web.********************.js 3.67 kB 0 B
dotcom-rendering/dist/9387.client.web.********************.js 13 kB 0 B
dotcom-rendering/dist/9396.client.web.********************.js 680 B 0 B
dotcom-rendering/dist/9430.client.web.********************.js 508 B 0 B
dotcom-rendering/dist/9707.client.web.********************.js 3.34 kB 0 B
dotcom-rendering/dist/9789.client.web.********************.js 922 B 0 B
dotcom-rendering/dist/AdPortals-importable.client.web.********************.js 3.76 kB +12 B (0%)
dotcom-rendering/dist/AlreadyVisited-importable.client.web.********************.js 424 B 0 B
dotcom-rendering/dist/AppsEpic-importable.client.web.********************.js 4.15 kB 0 B
dotcom-rendering/dist/AppsFooter-importable.client.web.********************.js 3.63 kB 0 B
dotcom-rendering/dist/AppsLightboxImage-importable.client.web.********************.js 3.02 kB 0 B
dotcom-rendering/dist/AppsLightboxImageStore-importable.client.web.********************.js 2.46 kB 0 B
dotcom-rendering/dist/AudioAtomWrapper-importable.client.web.********************.js 3.61 kB 0 B
dotcom-rendering/dist/AustralianTerritorySwitcher-importable.client.web.********************.js 2.04 kB 0 B
dotcom-rendering/dist/Branding-importable.client.web.********************.js 2.63 kB 0 B
dotcom-rendering/dist/braze-web-sdk-core.client.web.********************.js 36.9 kB 0 B
dotcom-rendering/dist/BrazeMessaging-importable.client.web.********************.js 1.91 kB 0 B
dotcom-rendering/dist/CalloutBlockComponent-importable.client.web.********************.js 6.76 kB 0 B
dotcom-rendering/dist/CalloutEmbedBlockComponent-importable.client.web.********************.js 5.78 kB 0 B
dotcom-rendering/dist/CardCommentCount-importable.client.web.********************.js 4.84 kB 0 B
dotcom-rendering/dist/Carousel-importable.client.web.********************.js 5.57 kB 0 B
dotcom-rendering/dist/CarouselForNewsletters-importable.client.web.********************.js 5.66 kB 0 B
dotcom-rendering/dist/ChartAtom-importable.client.web.********************.js 541 B 0 B
dotcom-rendering/dist/CommentCount-importable.client.web.********************.js 3.28 kB 0 B
dotcom-rendering/dist/DiscussionApps-importable.client.web.********************.js 2.46 kB 0 B
dotcom-rendering/dist/DiscussionMeta-importable.client.web.********************.js 4.05 kB 0 B
dotcom-rendering/dist/DiscussionWeb-importable.client.web.********************.js 1.67 kB 0 B
dotcom-rendering/dist/DocumentBlockComponent-importable.client.web.********************.js 3.6 kB 0 B
dotcom-rendering/dist/EmbedBlockComponent-importable.client.web.********************.js 4.16 kB 0 B
dotcom-rendering/dist/EnhancePinnedPost-importable.client.web.********************.js 2.01 kB 0 B
dotcom-rendering/dist/FetchOnwardsData-importable.client.web.********************.js 2.42 kB 0 B
dotcom-rendering/dist/FilterKeyEventsToggle-importable.client.web.********************.js 3.35 kB 0 B
dotcom-rendering/dist/FocusStyles-importable.client.web.********************.js 612 B 0 B
dotcom-rendering/dist/FollowWrapper-importable.client.web.********************.js 832 B 0 B
dotcom-rendering/dist/FooterLabel-importable.client.web.********************.js 342 B 0 B
dotcom-rendering/dist/frameworks.client.web.********************.js 20.7 kB 0 B
dotcom-rendering/dist/GetCricketScoreboard-importable.client.web.********************.js 3.81 kB 0 B
dotcom-rendering/dist/GetMatchNav-importable.client.web.********************.js 10.8 kB 0 B
dotcom-rendering/dist/GetMatchStats-importable.client.web.********************.js 1.66 kB 0 B
dotcom-rendering/dist/GetMatchTabs-importable.client.web.********************.js 2.65 kB 0 B
dotcom-rendering/dist/guardian-braze-components-banner.client.web.********************.js 15 kB 0 B
dotcom-rendering/dist/guardian-braze-components-end-of-article.client.web.********************.js 9.45 kB 0 B
dotcom-rendering/dist/GuideAtomWrapper-importable.client.web.********************.js 782 B 0 B
dotcom-rendering/dist/HeaderTopBar-importable.client.web.********************.js 12.3 kB 0 B
dotcom-rendering/dist/index.client.web.********************.js 47.6 kB +8 B (0%)
dotcom-rendering/dist/InstagramBlockComponent-importable.client.web.********************.js 3.69 kB 0 B
dotcom-rendering/dist/InteractiveAtomMessenger-importable.client.web.********************.js 856 B 0 B
dotcom-rendering/dist/InteractiveBlockComponent-importable.client.web.********************.js 6.09 kB 0 B
dotcom-rendering/dist/InteractiveContentsBlockComponent-importable.client.web.********************.js 4.7 kB 0 B
dotcom-rendering/dist/InteractiveSupportButton-importable.client.web.********************.js 3.49 kB 0 B
dotcom-rendering/dist/KeyEventsCarousel-importable.client.web.********************.js 4.59 kB 0 B
dotcom-rendering/dist/KnowledgeQuizAtom-importable.client.web.********************.js 3.54 kB 0 B
dotcom-rendering/dist/LatestLinks-importable.client.web.********************.js 2.21 kB 0 B
dotcom-rendering/dist/LightboxHash-importable.client.web.********************.js 436 B 0 B
dotcom-rendering/dist/LightboxLayout-importable.client.web.********************.js 6.46 kB 0 B
dotcom-rendering/dist/Liveness-importable.client.web.********************.js 4.95 kB 0 B
dotcom-rendering/dist/ManyNewsletterSignUp-importable.client.web.********************.js 6.63 kB 0 B
dotcom-rendering/dist/MapEmbedBlockComponent-importable.client.web.********************.js 5.69 kB 0 B
dotcom-rendering/dist/Metrics-importable.client.web.********************.js 2.31 kB 0 B
dotcom-rendering/dist/MostViewedFooter-importable.client.web.********************.js 4.04 kB 0 B
dotcom-rendering/dist/MostViewedFooterData-importable.client.web.********************.js 6.73 kB 0 B
dotcom-rendering/dist/MostViewedRightWrapper-importable.client.web.********************.js 4.44 kB 0 B
dotcom-rendering/dist/OnwardsUpper-importable.client.web.********************.js 4.05 kB 0 B
dotcom-rendering/dist/PersonalityQuizAtom-importable.client.web.********************.js 3.66 kB 0 B
dotcom-rendering/dist/ProfileAtom-importable.client.web.********************.js 543 B 0 B
dotcom-rendering/dist/ProfileAtomWrapper-importable.client.web.********************.js 801 B 0 B
dotcom-rendering/dist/PulsingDot-importable.client.web.********************.js 752 B 0 B
dotcom-rendering/dist/QandaAtom-importable.client.web.********************.js 540 B 0 B
dotcom-rendering/dist/ReaderRevenueDev-importable.client.web.********************.js 470 B 0 B
dotcom-rendering/dist/readerRevenueDevUtils.client.web.********************.js 1.9 kB 0 B
dotcom-rendering/dist/ReaderRevenueLinks-importable.client.web.********************.js 3.65 kB 0 B
dotcom-rendering/dist/RelativeTime-importable.client.web.********************.js 1.99 kB 0 B
dotcom-rendering/dist/RichLinkComponent-importable.client.web.********************.js 6.24 kB 0 B
dotcom-rendering/dist/SecureSignup-importable.client.web.********************.js 3.63 kB 0 B
dotcom-rendering/dist/SendAMessage-importable.client.web.********************.js 4.43 kB 0 B
dotcom-rendering/dist/SendTargetingParams-importable.client.web.********************.js 2.14 kB 0 B
dotcom-rendering/dist/sentry.client.web.********************.js 769 B 0 B
dotcom-rendering/dist/SetAdTargeting-importable.client.web.********************.js 481 B 0 B
dotcom-rendering/dist/ShareButton-importable.client.web.********************.js 1.52 kB 0 B
dotcom-rendering/dist/shimport.client.web.********************.js 2.79 kB 0 B
dotcom-rendering/dist/ShowHideContainers-importable.client.web.********************.js 645 B 0 B
dotcom-rendering/dist/ShowMore-importable.client.web.********************.js 5.72 kB 0 B
dotcom-rendering/dist/SignInGateCustomizableText.client.web.********************.js 955 B 0 B
dotcom-rendering/dist/SignInGateMain.client.web.********************.js 1.19 kB 0 B
dotcom-rendering/dist/SignInGateMainCheckoutComplete.client.web.********************.js 2.69 kB 0 B
dotcom-rendering/dist/SignInGateSelector-importable.client.web.********************.js 3.53 kB 0 B
dotcom-rendering/dist/SlotBodyEnd-importable.client.web.********************.js 4.6 kB +49 B (+1%)
dotcom-rendering/dist/SpotifyBlockComponent-importable.client.web.********************.js 5.52 kB 0 B
dotcom-rendering/dist/SubNav-importable.client.web.********************.js 2.24 kB 0 B
dotcom-rendering/dist/SupportTheG-importable.client.web.********************.js 3.78 kB 0 B
dotcom-rendering/dist/TableOfContents-importable.client.web.********************.js 3.16 kB 0 B
dotcom-rendering/dist/TimelineAtom-importable.client.web.********************.js 1.24 kB 0 B
dotcom-rendering/dist/TweetBlockComponent-importable.client.web.********************.js 1.02 kB 0 B
dotcom-rendering/dist/UnsafeEmbedBlockComponent-importable.client.web.********************.js 3.7 kB 0 B
dotcom-rendering/dist/VideoFacebookBlockComponent-importable.client.web.********************.js 5.69 kB 0 B
dotcom-rendering/dist/VineBlockComponent-importable.client.web.********************.js 3.54 kB 0 B
dotcom-rendering/dist/WeatherWrapper-importable.client.web.********************.js 5.46 kB 0 B
dotcom-rendering/dist/YoutubeBlockComponent-importable.client.web.********************.js 4.11 kB 0 B

compressed-size-action

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.

Strictly accurate

Comment on lines +746 to +747
| FETimelineBlockElement
| DCRTimelineBlockElement
Copy link
Contributor

Choose a reason for hiding this comment

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

Can it really be either? Once an FETimelineBlockElement is enhanced, it will either result in nothing or a DCRTimelineBlockElement

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, it can't. There are several elements in this model that can only exist in DCR, and replace the frontend elements that they're enhanced from. We should really split it into two models: one for frontend data, and one for DCR data once it's been parsed/enhanced.

@JamieB-gu JamieB-gu added the run_chromatic Runs chromatic when label is applied label Mar 28, 2024
@github-actions github-actions bot removed the run_chromatic Runs chromatic when label is applied label Mar 28, 2024
@JamieB-gu JamieB-gu merged commit e1e2213 into main Mar 28, 2024
32 checks passed
@JamieB-gu JamieB-gu deleted the model-timeline-elements branch March 28, 2024 13:38
@JamieB-gu JamieB-gu linked an issue Mar 28, 2024 that may be closed by this pull request
@prout-bot
Copy link

Seen on PROD (merged by @JamieB-gu 8 minutes and 47 seconds ago) Please check your changes!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Decide How Timeline Hierarchy Will Be Modelled
4 participants