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

Send site notification on Build status reporting failure and follow DRY #6033

Merged
merged 10 commits into from Aug 7, 2019

Conversation

@saadmk11
Copy link
Member

@saadmk11 saadmk11 commented Aug 2, 2019

ref: #6014

@saadmk11 saadmk11 changed the title Send site notification on Build status reporting failure Send site notification on Build status reporting failure and follow DRY Aug 3, 2019
@saadmk11
Copy link
Member Author

@saadmk11 saadmk11 commented Aug 3, 2019

As I was Adding the User communication part to the task I saw that we were using some of the same code more than once. So, I tried to follow DRY and moved some of the redundant code to projects.models.Project as methods. I think this approach is much cleaner and reusable for the future when we add other providers. :)

Copy link
Member

@ericholscher ericholscher left a comment

This looks like a good approach. We should make sure the messaging doesn't overwhelm the user. We definitely need to confirm it only shows up once even if the build fails multiple times (this would be a good test).

readthedocs/oauth/notifications.py Outdated Show resolved Hide resolved
try:
if build.project.remote_repository.account.provider == 'github':
service = GitHubService(
if provider_name == 'GitHub':
Copy link
Member

@ericholscher ericholscher Aug 6, 2019

This should be a constant. Also, why are we checking the name instead of build.project.remote_repository.account.provider like previously?

Copy link
Member Author

@saadmk11 saadmk11 Aug 7, 2019

previously we were just getting the provider name by using build.project.remote_repository.account.provider but now we have a better way project.git_provider_name as this actually checks which provider the project is from and project.git_service_class() get the actual class the projects needs (e.g: GitHubService) so we don't need that anymore.

readthedocs/oauth/notifications.py Outdated Show resolved Hide resolved
readthedocs/projects/tasks.py Outdated Show resolved Hide resolved
@saadmk11 saadmk11 closed this Aug 7, 2019
Pull Request Builder automation moved this from In progress to Done Aug 7, 2019
@saadmk11 saadmk11 reopened this Aug 7, 2019
Pull Request Builder automation moved this from Done to In progress Aug 7, 2019
@saadmk11 saadmk11 requested a review from ericholscher Aug 7, 2019
Copy link
Member

@ericholscher ericholscher left a comment

Looks good with a change to the notification type.

@@ -355,3 +355,6 @@
)

GITHUB_PR_PULL_PATTERN = 'pull/{id}/head:external-{id}'

# Git provider names
GITHUB = 'GitHub'
Copy link
Member

@ericholscher ericholscher Aug 7, 2019

This isn't a good name, since it has specialized caps. It should likely be GITHUB_BRAND or something,

Copy link
Member Author

@saadmk11 saadmk11 Aug 7, 2019

GITHUB_PROVIDER_NAME maybe?

@saadmk11
Copy link
Member Author

@saadmk11 saadmk11 commented Aug 7, 2019

Updated the Changes :)

@ericholscher ericholscher merged commit e80b0da into readthedocs:master Aug 7, 2019
1 check passed
Pull Request Builder automation moved this from In progress to Done Aug 7, 2019
@saadmk11 saadmk11 deleted the user-communication branch Aug 7, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants