Skip to content

Remove json field from RemoteRepositoryRelation and RemoteOrganizationRelation model #7993

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

Conversation

saadmk11
Copy link
Member

@saadmk11 saadmk11 commented Mar 8, 2021

This PR removes json field from RemoteRepositoryRelation and RemoteOrganizationRelation model as the json field is no longer required or used in the codebase, we are storing the remote_id separately in another field.

@saadmk11 saadmk11 requested a review from humitos March 8, 2021 12:30
Copy link
Member

@humitos humitos left a comment

Choose a reason for hiding this comment

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

Great! Thanks a lot!

Comment on lines 57 to 59
try:
repo_id = json.loads(project.remote_repository.json).get('id')
repo_id = project.remote_repository.remote_id
except Exception:
Copy link
Member

Choose a reason for hiding this comment

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

We could probably remove the try/except clause here as well.

Copy link
Member Author

Choose a reason for hiding this comment

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

if the project was imported manually it would throw an exception as stated here.

# Handle "Manual Import" when there is no RemoteRepository

Copy link
Member

Choose a reason for hiding this comment

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

He, I didn't read the following line.

However, the previous case would have failed because the json.loads would have failed. Now, accessing remote_id will return just None and won't fail. I think we should check if project.remote_repository.remote_id is None instead of the try/except, right?

Copy link
Member Author

Choose a reason for hiding this comment

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

In this case the project.remote_repository wont exist and throw RemoteRepositroy.DoesNotExist Exception.

Copy link
Member

Choose a reason for hiding this comment

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

Good point! Can we catch that exception here then instead of the generic Exception?

@saadmk11 saadmk11 requested a review from humitos March 8, 2021 16:33
@humitos humitos merged commit 5317c80 into readthedocs:remote-repository-normalization Mar 8, 2021
@saadmk11 saadmk11 deleted the remove-json-field branch March 8, 2021 18:22
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