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

feat: index chart entities into charts_x_entities table #3418

Merged
merged 8 commits into from
Mar 28, 2024

Conversation

marcelgerber
Copy link
Member

@marcelgerber marcelgerber commented Mar 27, 2024

Implements #3401.

Currently, this is just a batch script that will update all charts.
But it is written in such a way that it will be easy to hook into it in the future, and we could call obtainAvailableEntitiesForGrapherConfig in a server-side onSave handler, and update charts_x_entities for that chart only.

Ready for review already, but some TODOs still:

  • Think about handling of Marimekko, slope, scatter charts; where an entity not being selected doesn't mean that it's invisible
  • Does it make sense to move obtainEntityNameToIdMap into an Entity.ts model file? We'll probably need the inverse, too...
  • Makefile?
  • yargs, and === "main" check

On my local machine, running the script takes 7.5 minutes.
The resulting table has 625,676 rows.

@marcelgerber marcelgerber changed the title wip(entities): entity indexing script feat: index chart entities u Mar 27, 2024
@marcelgerber marcelgerber changed the title feat: index chart entities u feat: index chart entities into charts_x_entities table Mar 27, 2024
@marcelgerber marcelgerber marked this pull request as ready for review March 27, 2024 23:10
@marcelgerber marcelgerber changed the base branch from algolia-geographic-entities to master March 27, 2024 23:29
Copy link
Contributor

@danyx23 danyx23 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! Could you add a DbPlainChartXEntity type for completeness and add a similar type in the ETL (or ask Mojmir to do it) and add it to datasette so it will be exported?

Relevant ETL place: https://github.com/owid/etl/blob/master/etl/grapher_model.py
And datasette: https://github.com/owid/analytics/blob/e028289496b31f708fbd65cbae1bfa9b5f68d27d/snail/sqlite_from_mysql.py#L102-L129

baker/updateAvailableEntities.ts Outdated Show resolved Hide resolved
baker/updateAvailableEntities.ts Outdated Show resolved Hide resolved
@marcelgerber marcelgerber merged commit e352e83 into master Mar 28, 2024
37 of 38 checks passed
@marcelgerber marcelgerber deleted the available-entities-accurate branch March 28, 2024 14:19
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