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

🔨 migrate slope charts / TAS-721 #4210

Closed
wants to merge 26 commits into from

Conversation

sophiamersmann
Copy link
Member

@sophiamersmann sophiamersmann commented Nov 25, 2024

WIP

A slope chart is either:

  • migrated to work as a stand-alone chart
  • added to the corresponding line chart and deleted

Migration

  • Stand-alone charts
    • The migration chooses a random set of entities to be initially selected
      • It's possible that we select a sub-optimal set of entities that don't have data for the default years
    • It also makes sure that entity selection not disabled and the (line) legend is not hidden
  • Line+slope charts
    • The migration adds a "slope" tab to existing line charts if the matching is unambiguous

Step by step

  • Run the queries below against the live db
  • Merge this PR that runs the migration
  • Go through referenced slope charts and update the links to point to the slope tab of the corresponding line chart (todo: google sheet)
  • Delete slope charts manually (todo: google sheet)
  • Go through stand-alone slope charts and check that their selection is ok (todo: google sheet)
  • Run sync script for chart configs in R2 (how do I do that?)
Query: slope charts
with line_charts as (select c.id,
                            c.configId,
                            cc.slug,
                            cc.full ->> '$.dimensions[0].variableId' as variableId,
                            cc.full ->> '$.selectedEntityNames'      as selectedEntityNames
                     from charts c
                              join chart_configs cc on c.configId = cc.id
                     where coalesce(cc.full ->> '$.type', 'LineChart') = 'LineChart'
                       and json_length(cc.full, '$.dimensions') = 1
                       and cc.full ->> '$.isPublished' = 'true'),
     slope_charts as (select c.id,
                             c.configId,
                             cc.slug,
                             cc.full ->> '$.dimensions[0].variableId' as variableId,
                             cc.full ->> '$.selectedEntityNames'      as selectedEntityNames,
                             cc.full ->> '$.includedEntities'         as includedEntities,
                             cc.full ->> '$.excludedEntities'         as excludedEntities
                      from charts c
                               join chart_configs cc on c.configId = cc.id
                      where cc.full ->> '$.type' = 'SlopeChart'
                        and cc.full ->> '$.isPublished' = 'true')
select sc.variableId          as variableId,
       sc.id                  as slopeChartId,
       sc.configId            as slopeConfigId,
       sc.slug                as slopeSlug,
       lc.id                  as lineChartId,
       lc.configId            as lineConfigId,
       lc.slug                as lineSlug,
       sc.selectedEntityNames as slopeEntities,
       lc.selectedEntityNames as lineEntities,
       sc.includedEntities,
       sc.excludedEntities
from slope_charts sc
         left join line_charts lc on sc.variableId = lc.variableId;
Query: References
select pg.slug as gdocsSlug, cc.slug as slopeSlug
from charts c
join chart_configs cc on cc.id = c.configId
join posts_gdocs_links pgl on pgl.target = cc.slug
join posts_gdocs pg on pgl.sourceId = pg.id
where pgl.linkType = 'grapher'
and cc.full ->> '$.type' = 'SlopeChart';

To do

  • Update queries once the chartTypes PR landed

@sophiamersmann sophiamersmann changed the title 🔨 migrate slope charts 🔨 migrate slope charts / TAS-721 Nov 25, 2024
Copy link

Migrate slope charts

@owidbot
Copy link
Contributor

owidbot commented Nov 25, 2024

Quick links (staging server):

Site Dev Site Preview Admin Wizard Docs

Login: ssh owid@staging-site-migrate-slopes-viz

SVG tester:

Number of differences (default views): 538 (65fbbc) ❌
Number of differences (all views): 0 ✅

Edited: 2024-11-26 17:57:28 UTC
Execution time: 1.29 seconds

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.

2 participants