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

DESENG-632 Add DB tables & API routes #2533

Merged
merged 4 commits into from
Jun 4, 2024

Conversation

Baelx
Copy link
Collaborator

@Baelx Baelx commented Jun 4, 2024

Issue #: https://github.com/bcgov/met-public/issues/

Description of changes:

  • Add DB tables, models
  • Add API routes
  • Update Readme for migrations folder

This is a partial PR.

  • Tests will come later, as will securing API routes
  • Changelog will be updated when all is merged into main

@Baelx Baelx changed the base branch from main to feature/deseng623 June 4, 2024 18:23
@Baelx Baelx marked this pull request as ready for review June 4, 2024 19:13
@Baelx Baelx requested a review from NatSquared June 4, 2024 19:13
Copy link
Contributor

@NatSquared NatSquared 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! I would consider either:

  • not removing the endpoints for adding a language
    OR
  • also removing the endpoints for deleting languages

@@ -0,0 +1,27 @@
"""
Relax language table constraints.
Copy link
Contributor

Choose a reason for hiding this comment

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

like, just chill out, dude

branch_labels = None
depends_on = None

with open("migrations/supported_languages.json", "r") as read_file:
Copy link
Contributor

Choose a reason for hiding this comment

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

Has maintainability been considered here? What will it look like when we need to add or remove a language? Can we still use the same JSON file or will we be manually migrating to match any edits made?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Great point!

Adding/removing languages in the future would be done with a DB migration. I don't expect us to have to do so that often. Given that, maybe it would be better to rename supported_languages to initial_languages or something, knowing that it may not be the exhaustive in the long term.

I could have also not had a separate file but I felt the size of the migration file would be super huge and less readable that way. Do you think maybe I should just move the list into the migration file given that they'll be the ultimate source of truth?

request_json, 'language'
languages = LanguageService.get_languages()
return (
jsonify(LanguageSchema(many=True).dump(languages)),
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this call to jsonify necessary if dump() already produces a json string?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Oh I missed this, this might just solve an issue I was having... Thanks

"""Resourse for removing language-tenant relationships."""

@staticmethod
# @_jwt.requires_auth
Copy link
Contributor

Choose a reason for hiding this comment

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

I realize this is temporary, but do remember to add appropriate authentication to your routes before merging to main

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I made a note about it in the PR description but yes for sure, I'll have to circle back to auth once I push changes for the frontend. It'll be easier to test it when I'm making requests from the browser

@@ -24,22 +23,6 @@ def get_languages():
languages_records = Language.get_languages()
return LanguageSchema(many=True).dump(languages_records)

@staticmethod
def create_language(language_data):
"""Create language."""
Copy link
Contributor

Choose a reason for hiding this comment

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

If we can delete languages, we should probably still be able to add them as well, otherwise the number of languages can only decrease with time. Is there a reason all this code was removed?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

If I left in a call to deleting languages themselves then I'll be removing it. Great point

Copy link
Contributor

@NatSquared NatSquared 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! Thanks for taking the time to address my comments

if success:
return 'Successfully deleted language', HTTPStatus.NO_CONTENT
raise ValueError('Language not found')
return 'Successfully deleted language-tenant mapping', HTTPStatus.NO_CONTENT
Copy link
Contributor

Choose a reason for hiding this comment

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

I appreciate you updating the language to remain accurate :)

Copy link

sonarcloud bot commented Jun 4, 2024

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud

@Baelx Baelx merged commit 8f09e10 into feature/deseng623 Jun 4, 2024
1 check passed
@Baelx Baelx deleted the feature/deseng623-add-api-routes branch June 4, 2024 22:33
Baelx added a commit that referenced this pull request Jun 19, 2024
…odes (#2540)

* DESENG-632 Add DB tables & API routes (#2533)

* 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]>

* Feature/deseng623 - Add frontend, update backend routes to use tenant 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]>

* DESENG-623 Add frontend tests, trim api tests

* DESENG-623 Add frontend tests

* DESENG-623 Add new tests, fix broken ones, merge migrations

* DESENG-623 Update changelog

* DESENG-623 fix linting and tests, clean up code further

---------

Co-authored-by: Alex <[email protected]>
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