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

Implement thumbnails for multidimensional data pages #4475

Merged
merged 4 commits into from
Jan 29, 2025
Merged

Conversation

rakyi
Copy link
Contributor

@rakyi rakyi commented Jan 22, 2025

We can't use a dynamic thumbnail for social media previews, because the meta tags are generated during baking. We could switch to dynamic thumbnails if/when we move the Grapher pages to dynamic rendering, i.e Cloudflare functions.

Resolves #4456

@rakyi rakyi requested a review from ikesau January 22, 2025 15:19
@rakyi rakyi marked this pull request as draft January 22, 2025 15:28
@owidbot
Copy link
Contributor

owidbot commented Jan 22, 2025

Quick links (staging server):

Site Dev Site Preview Admin Wizard Docs

Login: ssh owid@staging-site-mdim-thumbnails

SVG tester:

Number of differences (default views): 0 ✅
Number of differences (all views): 0 ✅

Edited: 2025-01-28 11:05:10 UTC
Execution time: 1.24 seconds

@rakyi rakyi marked this pull request as ready for review January 22, 2025 15:46
}
// Due to thumbnails not taking into account URL parameters, they are often inaccurate on
// social media. We decided to remove them and use a single thumbnail for all charts.
// See https://github.com/owid/owid-grapher/issues/1086
Copy link
Member

Choose a reason for hiding this comment

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

Huh? We do show chart previews based on query params

See rewriteMetaTags

image image

So at least one of us must be confused 😅

Copy link
Member

@ikesau ikesau Jan 23, 2025

Choose a reason for hiding this comment

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

Once we've resolved this, I'll actually test the PR 👍

(Though, I might need a refresher on how to get MDD's running locally 🙂)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh, that's pretty cool that we do that. I copy-pasted the existing code from the data page, so I'll remove those comments in both places then. And, it works the same for mdims out of the box:

http://staging-site-mdim-thumbnails/grapher/mdd-demo-poverty?povertyLine=30&metric=share

Copy link
Contributor Author

@rakyi rakyi Jan 24, 2025

Choose a reason for hiding this comment

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

Testing mdims locally is quite complicated. You need a relatively fresh copy of the DB. The previews are available at an admin sub-path, e.g. http://localhost:3030/admin/grapher/mdd-demo-poverty (even if the mdim is not published). Let me know if you'll need help with it.

@rakyi rakyi requested a review from ikesau January 24, 2025 10:34
@rakyi rakyi force-pushed the mdim-thumbnails branch 2 times, most recently from 6e947ba to 3955aa2 Compare January 27, 2025 12:21
}
const imageUrl: string = urljoin(baseUrl, "default-grapher-thumbnail.png")
Copy link
Member

Choose a reason for hiding this comment

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

This isn't getting overwritten correctly in staging it seems

image

I can't debug it correctly because my local version of the MDD previews don't render when served through the wrangler. Also, even when served by the admin server I get "No table loaded yet" - do you know what's going on there?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I had to rebake the page first (since it was missing due to a bug I'm fixing here), but I see it rewritten there:

image

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have some ideas on what might be going on with your local dev setup, and it would be easiest if we could have a call to debug it together. Short summary:

  • Make sure you have the latest code and data in the DB

  • To see the normal mdim page at /grapher (not the admin preview) you need to set published to 1 in multi_dim_data_pages and run the migration script, so it propagates to chart configs with:

    yarn tsx --tsconfig tsconfig.tsx.json devTools/migrateMultiDimConfigs/migrateMultiDimConfigs.ts
    

    (I'll be adding an admin for publishing mdims later this cycle.)

@rakyi rakyi force-pushed the mdim-thumbnails branch 2 times, most recently from 57677d5 to 39ac01f Compare January 28, 2025 10:49
Copy link
Contributor Author

rakyi commented Jan 28, 2025

Copy link
Member

@ikesau ikesau left a comment

Choose a reason for hiding this comment

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

Huzzah! 🙌

Code looks good and the feature works 😎

Copy link
Contributor Author

rakyi commented Jan 29, 2025

Merge activity

  • Jan 29, 6:09 AM EST: A user started a stack merge that includes this pull request via Graphite.
  • Jan 29, 6:10 AM EST: Graphite rebased this pull request as part of a merge.
  • Jan 29, 6:10 AM EST: A user merged this pull request with Graphite.

rakyi added 4 commits January 29, 2025 11:09
We can't use a dynamic thumbnail, because the meta tags are generated
during baking. We could switch to dynamic thumbnails if/when we move the
Grapher pages to dynamic rendering, i.e Cloudflare functions.
We now rewrite the image meta tags dynamically in Cloudflare functions
to take query params into consideration.
This makes it more general and usable also for other routes, such as
data download.
@rakyi rakyi merged commit 92d66a0 into master Jan 29, 2025
16 of 18 checks passed
@rakyi rakyi deleted the mdim-thumbnails branch January 29, 2025 11:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Dynamic thumbnails for multidimensional data page views
3 participants