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

Ran linting, updated to have a single /cleanup endpoint #39

Merged

Conversation

jcadam14
Copy link
Collaborator

Closes #35

Added the following paths:

/v1/cleanup/{lei} <- All institutions and filings for a LEI
/v1/cleanup/institution/{lei} <- Institutions for a LEI
/v1/cleanup/filing/{lei}/{period_code} <- Filings for a LEI for a given period
/v1/cleanup/submissions/{lei}/{period_code} <- Submissions for a LEI for a given period

Ran linting, so some of the changes are black/ruff adjustments

  • Created a cleanup.py Router with a single endpoint for /v1/cleanup/{lei}
  • Updated main.py so the app uses the one router currently
  • Left the existing code in there, with the previous endpoints, "just in case" we want to include those as separate endpoints to hit. Right now, only the /cleanup one is planned on being used. But @guffee23 / @nargis-sultani can play with adding the other endpoints as additional routers as desired.
  • Pulled out code that deletes institutions and filing data to "delete_helper" functions in each of the filing and institution router classes. Made them usable by the /cleanup endpoint as well as the previous separate set of endpoints (again just in case we want all that modularity in there, none of the code was replaced/removed)

@jcadam14 jcadam14 self-assigned this Sep 16, 2024
@jcadam14 jcadam14 linked an issue Sep 16, 2024 that may be closed by this pull request
Copy link
Member

@hkeeler hkeeler left a comment

Choose a reason for hiding this comment

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

Overall looks great. Just a couple nitpicks in there.

Comment on lines 45 to 46
except Exception as e:
raise e
Copy link
Member

Choose a reason for hiding this comment

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

Do you need to catch it if you you're just going to re-raise it?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Updated to instead raise the following like we do with our other exceptions, gracefully handling this condition:

            raise RegTechHttpException(
                status_code=HTTPStatus.INTERNAL_SERVER_ERROR,
                name="Delete Filing Server Error",
                detail=f"Server error while trying to delete filing for LEI {lei}.",
            ) from e

Comment on lines +51 to +52
if not delete_domains:
logger.error(f"Domain(s) for LEI {lei} not deleted.")
Copy link
Member

Choose a reason for hiding this comment

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

I'm guessing there are some test scenarios where there won't be email domains...like if you're testing that that user cannot get past that step in the process without those domains. :) It doesn't seem like an error in that case. Maybe a warn?

Comment on lines +54 to +56
delete_sbl_type = repo.delete_sbl_type_by_lei(session, lei)
if not delete_sbl_type:
logger.error(f"sbl type(s) for LEI {lei} not deleted.")
Copy link
Member

Choose a reason for hiding this comment

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

Same.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Honestly looking at the repo code for deleting domains and types, I don't know how this code will even be hit. If there isn't a domain or type, the filter will just not do anything, but the return object for delete_domains and delete_sbl_type will always exist. So that logger code wouldn't be hit. If an exception is hit while trying to delete either, it would be thrown up in the response and the logger code wouldn't be hit.

I'm going to write a story for Nargis to rework the code for the repo or this section to properly check if the domains and types exist and log a warning because yeah I think these loggers are unreachable.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Created #40 if you want to check if that properly captures the issue here.

@jcadam14 jcadam14 requested a review from hkeeler September 17, 2024 14:43
@jcadam14 jcadam14 merged commit 3b175d4 into main Sep 17, 2024
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.

Combine institution and filing cleanup to single endpoint
2 participants