Add plants:sync_common_names for the ECHOcommunity plant migration - #120
Merged
Conversation
Syncs common names from ECHOcommunity and sets the primary flag per language. Why primary matters: the API only uses a language when a primary is set in it, otherwise falling back to English. A language with names but no primary therefore shows English, so a Malay reader saw an English name while Malay names sat unused in the same table. Which name is primary is decided upstream in the migration workspace, where the rules and their reasoning live together; this applies that decision. Additive for names - missing ones are created, existing ones matched case-insensitively on (name, language) and never duplicated. Deleting a name ECHOcommunity no longer lists is an editorial act, not a migration one. Rehearsed against staging: 57 names created, 1741 already present, 546 primary flags set, 16 cleared, 0 failures. Primary coverage went from 1 of 186 Thai names to 207 of 245, Spanish 53 to 107, French 40 to 74. Full suite 2310 examples, 0 failures. Whole-repo rubocop clean.
Names match case-insensitively, so 'Velvet Bean' and 'velvet bean' are the same name. ECHOcommunity's casing is the curated one, and leaving the API holding a variant meant the title sync pushed that variant back - 'Velvet Bean' became 'velvet bean' on the public site. Full suite 2311 examples, 0 failures. Whole-repo rubocop clean.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Phase 1 of the plant-data ownership migration. Independent of #117, #118 and
#119 — merge in any order.
Syncs common names from ECHOcommunity and sets the
primaryflag per language.Why the primary flag is the point
Plant#primary_common_name_for_localeonly uses a language when aprimaryisset in it, otherwise falling back to English. So a language holding names but no
primary displays English, and the translated names sit unused in the same
table.
That was the state before this: Thai had 1 primary across 186 names. A Thai
reader saw English names for essentially every plant, with Thai names present
and unreachable.
Which name becomes primary
Decided upstream in the migration workspace, where the rules and their reasoning
live together, so this stays a simple apply step. In order:
Rule 3 does the heavy lifting because ECHOcommunity titles are composites —
"Coriander / Cilantro", "Caigua (achogcha, archucha, caihua…)" — so exact
matching alone resolved almost nothing. Where none of those apply it falls back
to word overlap, then to the lowest-id name, which at least yields a name in
the reader's language rather than English.
Behaviour
Additive for names: missing ones are created, existing ones matched
case-insensitively on
(name, language)and never duplicated. Deleting a nameECHOcommunity no longer lists is an editorial act, not a migration one. The
primaryflag is synced in both directions, since exactly one name per languageshould carry it.
Rehearsed against staging
57 names created, 1,741 already present, 546 primary flags set, 16 cleared, no
failures. Coverage afterwards: