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

Update Feast model to draw data from new card meta #1612

Merged
merged 2 commits into from
Aug 12, 2024

Conversation

jonathonherbert
Copy link
Contributor

@jonathonherbert jonathonherbert commented Jul 30, 2024

What's changed?

Updates our Feast model to draw data from the new card meta introduced in #1589, #1607, and #1609.

How to test

  • The automated tests should pass ✅
  • In Fronts CODE, create an issue with lots of different card types, and hit publish.
  • Ensure there are no error logs (example logs.)
  • Check what was published by visiting the relevant content endpoint, e.g recipes.code.dev-guardianapis.com/feast-northern-hemisphere/all-recipes/2024-08-01/curation.json

For example, for the input:

Screenshot 2024-08-02 at 14 54 15

We get the output:

Expand to see JSON
[
    {
        "id": "7018406a-e9a0-442b-80d8-f22cba53ceee",
        "title": "Dish of the day",
        "body": "",
        "items": [
            {
                "backgroundHex": "#BB3B80",
                "id": "profile/yotamottolenghi",
                "bio": "Yotam Ottolenghi is  chef-patron of the Ottolenghi delis and the Nopi and Rovi restaurants. He has  published 10 bestselling cookbooks",
                "foregroundHex": "#F9F9F5"
            },
            {
                "darkPalette": {
                    "backgroundHex": "#363632",
                    "foregroundHex": "#FCF1F0"
                },
                "image": "https://uploads.guim.co.uk/2024/03/21/Baking.png",
                "title": "Sweet treats",
                "lightPalette": {
                    "backgroundHex": "#F9F9F5",
                    "foregroundHex": "#DB2712"
                },
                "recipes": [
                    "c2c9118b7e7b4a4aae48f31d4704dbd1",
                    "ae779e4975904ba6a601449e513d88f7"
                ]
            },
            {
                "recipe": {
                    "id": "c2c9118b7e7b4a4aae48f31d4704dbd1"
                }
            },
            {
                "recipe": {
                    "id": "ae779e4975904ba6a601449e513d88f7"
                }
            }
        ]
    },
    {
        "id": "a9949d60-2b76-4f71-88ba-4e7ff9636c71",
        "title": "Collection 2",
        "body": "",
        "items": []
    },
    {
        "id": "914bad50-1493-41c8-b3da-6a1bde94ab42",
        "title": "Collection 3",
        "body": "",
        "items": []
    },
    {
        "id": "ec085650-b225-478a-914f-4cb3efb22ce4",
        "title": "Collection 4",
        "body": "",
        "items": []
    },
    {
        "id": "bdd83158-62c7-4a1a-a4d6-75786d4a397d",
        "title": "Collection 5",
        "body": "",
        "items": []
    },
    {
        "id": "8ba7b176-3677-4559-9479-79be518276bf",
        "title": "Collection 6",
        "body": "",
        "items": []
    },
    {
        "id": "c9ae61e9-29fd-44ea-ae85-637d9be987d6",
        "title": "Collection 7",
        "body": "",
        "items": []
    },
    {
        "id": "368b0a3f-e7d6-4f0e-963b-c216e78f8370",
        "title": "Collection 8",
        "body": "",
        "items": []
    },
    {
        "id": "008aef4d-73a3-4ed4-9ac0-563df9388398",
        "title": "Collection 9",
        "body": "",
        "items": []
    }
]

Checklist

General

  • 🤖 Relevant tests added
  • ✅ CI checks / tests run locally
  • 🔍 Checked on CODE

Client

  • 🚫 No obvious console errors on the client (i.e. React dev mode errors)
  • 🎛️ No regressions with existing user interactions (i.e. all existing buttons, inputs etc. work)
  • 📷 Screenshots / GIFs of relevant UI changes included

Copy link
Contributor

@emdash-ie emdash-ie left a comment

Choose a reason for hiding this comment

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

Looks good!

Enabling some unused warnings from the scala compiler shows a number of unused imports and parameters – it’d be worth us cleaning those up in a subsequent PR.

@@ -29,7 +30,20 @@ class FeastPublicationTarget(snsClient: AmazonSNS, config: ApplicationConfigurat
bio = metadata.flatMap(_.bio),
backgroundHex = metadata.flatMap(_.theme.map(_.palette.backgroundHex)),
foregroundHex = metadata.flatMap(_.theme.map(_.palette.foregroundHex)))
case _:EditionsFeastCollection => FeastCollection(byline=None, darkPalette=None, image=None, body=None, title="", lightPalette=None, recipes=List.empty)
case EditionsFeastCollection(id, addedOn, metadata) =>
Copy link
Contributor

Choose a reason for hiding this comment

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

The id and addedOn pattern variables here are unused (confirmed by adding -Wunused:patvars to scalacOptions), as is the addedOn variable on line 35. Just wanted to confirm that’s intended! (I’d be tempted to prefix their names with an underscore to indicate they’re deliberately not used.)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Intentional as there's no place in the downstream Feast model for these values, AFAIK (ids are for the Fronts relational model, and Feast doesn't care when these items were initially curated), so I've cleaned up as you've suggested in ca5758a.

@emdash-ie
Copy link
Contributor

I should note I haven’t tested this on CODE yet, and from the bullet point in the PR description it sounds like you haven’t either. We should do that before merge: I’ll try to get to it tomorrow.

@emdash-ie
Copy link
Contributor

Ok, deployed to CODE, created an issue, published it, saw no errors in the logs. All good!

One behaviour surprised me: I can drag recipes into a collection from the clipboard, but not from the search result pane on the left. I assume that’s already known about and we have a trello card to fix it, but I wanted to mention it just in case.

@jonathonherbert
Copy link
Contributor Author

Apologies, should have updated the PR description – this was tested in CODE, and thank you for testing, too!

Spot on re: compiler warnings. It looks like you've raised a draft PR for that: thank you! Happy to take that forward, or would you like to continue?

> One behaviour surprised me: I can drag recipes into a collection from the clipboard, but not from the search result pane on the left. I assume that’s already known about and we have a trello card to fix it, but I wanted to mention it just in case.

This is a bug, thank you for spotting! This PR has a clear backend focus, so we'll card and fix in another PR.

@jonathonherbert jonathonherbert merged commit e70666f into main Aug 12, 2024
12 checks passed
@jonathonherbert jonathonherbert deleted the jsh/feast-snags-chef-bio branch August 12, 2024 11:25
@prout-bot
Copy link

Seen on PROD (merged by @jonathonherbert 6 minutes and 23 seconds ago) Please check your changes!

@emdash-ie
Copy link
Contributor

Spot on re: compiler warnings. It looks like you've raised a draft PR for that: thank you! Happy to take that forward, or would you like to continue?

No strong feelings! If you want to, go for it – I’ll get to it when I have some time.

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

Successfully merging this pull request may close these issues.

3 participants