-
Notifications
You must be signed in to change notification settings - Fork 19
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
Feature/deseng623 Add language selector UI based roughly on ISO 639 codes #2540
Conversation
* DESENG-632 Add DB tables & API routes * DESENG-623 fix linting * DESENG-623 Move language to migration file, remove delete crud language route * DESENG-623 Remove ability to delete language --------- Co-authored-by: Alex <[email protected]>
… short name (#2538) * DESENG-623 Add frontend, update backend routes * DESENG-623 Add api route updates, correct linting * DESENG-623 Correctly invoke autocomplete api to disable claering --------- Co-authored-by: Alex <[email protected]>
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2540 +/- ##
==========================================
- Coverage 75.98% 75.93% -0.05%
==========================================
Files 603 604 +1
Lines 21800 21807 +7
Branches 1678 1689 +11
==========================================
- Hits 16564 16559 -5
- Misses 4974 4985 +11
- Partials 262 263 +1
Flags with carried forward coverage won't be shown. Click here to find out more.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! A few things to review but all in all this seems like a robust start to the language system!
## Languages | ||
|
||
The list of languages in `versions/c656f3f82334_add_languages_and_tenant_mapping.py` has been taken from [https://www.w3schools.com/tags/ref_language_codes.asp](https://www.w3schools.com/tags/ref_language_codes.asp) and modified slightly to remove duplicate or multiple language codes per language. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you starting a pattern of documenting large data dumps with their migration IDs? I see promise in that approach!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I kinda thought it would be nice to have transparency with this migration anyway! Just to let future devs know we didn't pull this list out of nowhere
met-api/migrations/alembic.ini
Outdated
@@ -8,6 +8,9 @@ | |||
# the 'revision' command, regardless of autogenerate | |||
# revision_environment = false | |||
|
|||
# Enables albemic CLI commands like 'history,' 'branches,' etc. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for adding this shortcut! Just double-check the spelling of "alembic":
# Enables albemic CLI commands like 'history,' 'branches,' etc. | |
# Enables Alembic CLI commands like 'history,' 'branches,' etc. |
@@ -0,0 +1,27 @@ | |||
""" | |||
Merge albembic revisions that: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Merge albembic revisions that: | |
Merge Alembic revisions that: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lol, I'm getting creative with the spelling a few different ways
"iso_code": "ce" | ||
}, | ||
{ | ||
"language": "Chichewa, Chewa, Nyanja", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume we are intentionally remaining neutral in the cases where languages have multiple names
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nevermind; this is specified in the ticket
const mockSecondLanguage = { | ||
id: 90, | ||
code: 'tlh', | ||
name: 'Klingon', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like these test languages! 😉
test('Language selection updates', async () => { | ||
await addOrRemoveLanguage('gdx', [mockLanguage, mockSecondLanguage], [mockLanguage]); | ||
expect(languageService.postTenantLanguage).toHaveBeenCalledWith('gdx', mockSecondLanguage.id); | ||
await addOrRemoveLanguage('gdx', [mockLanguage], [mockLanguage, mockSecondLanguage]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for adding high-quality tests for your components! If it's not too much work, consider also using fired events to replicate actual user keystrokes and clicks on the DOM.
|
||
def upgrade(): | ||
for index, value in enumerate(language_data): | ||
op.execute("INSERT INTO language (created_date, updated_date, id, name, code) VALUES ('{0}', '{0}', '{1}', '{2}', '{3}')".format(sa.func.now(), index, value['language'], value['iso_code'])) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
to avoid ID collisions, you may want to drop the existing languages in the table, unless this table is known to be empty
@@ -876,8 +869,7 @@ def factory_enagement_content_model( | |||
def engagement_content_model_with_language(): | |||
"""Produce a engagement content model instance with language.""" | |||
content_model = factory_enagement_content_model() | |||
language_model = factory_language_model({'code': 'en', 'name': 'English'}) | |||
return content_model, language_model | |||
return content_model |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function is now just a wrapper for factory_enagement_content_model()
and should be replaced with such to avoid redundancy.
Quality Gate passedIssues Measures |
Issue #: https://github.com/bcgov/met-public/issues/
Description of changes:
Note for reviewer Most of this work has already been reviewed. This PR merges that previous work into main and introduces new code for: