Skip to content

feat(gh-comments): Queuing Logic #50865

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

Merged
merged 12 commits into from
Jun 15, 2023

Conversation

AniketDas-Tekky
Copy link
Contributor

Add task queuing logic to post process, specifically in process_commit_context when a suspect committer is established.

@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Jun 13, 2023
@AniketDas-Tekky AniketDas-Tekky requested a review from a team June 13, 2023 23:31
@AniketDas-Tekky AniketDas-Tekky marked this pull request as ready for review June 13, 2023 23:32
@AniketDas-Tekky AniketDas-Tekky requested a review from a team as a code owner June 13, 2023 23:32
Mock(
return_value={
"commitId": "asdfwreqr",
"committedDate": "2023-02-14T11:11Z",
Copy link
Member

Choose a reason for hiding this comment

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

Isn't it better to add a date() here so you make sure in tests the commit is always recent?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

the commit date isn't important in this case. I'd rather just mock a response once here and have the object be fixed.

)
if (
pr.exists()
and pr[0].date_added >= datetime.now(tz=timezone.utc) - timedelta(days=30)
Copy link
Member

Choose a reason for hiding this comment

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

Would pr ever include more than one object? and if so why do we choose pr[0] over the others?

Copy link
Member

Choose a reason for hiding this comment

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

pr is technically a query so we might want to call it pr_query. we could also use get() but get() throws an error if the item doesn't exist or if multiple items exist that match the criteria

Copy link
Member

Choose a reason for hiding this comment

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

although we should only have one match so we could use get()

Copy link
Member

@cathteng cathteng 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 to me aside from a few nits and small q's

)
if (
pr.exists()
and pr[0].date_added >= datetime.now(tz=timezone.utc) - timedelta(days=30)
Copy link
Member

Choose a reason for hiding this comment

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

although we should only have one match so we could use get()

),
)
@patch("sentry.tasks.integrations.github.pr_comment.comment_workflow.delay")
class TestGHCommentQueuing(TestCommitContextMixin):
Copy link
Member

Choose a reason for hiding this comment

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

does putting all the patches before the class mean that all the patches are applied to the tests inside the class?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yup! Saves on code repetition. I think you can override it too if you have one or two tests that want a different patch

@AniketDas-Tekky AniketDas-Tekky merged commit 115b032 into master Jun 15, 2023
@AniketDas-Tekky AniketDas-Tekky deleted the adas/gh-comment-bot/queuing-logic branch June 15, 2023 21:02
@github-actions github-actions bot locked and limited conversation to collaborators Jul 1, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Scope: Backend Automatically applied to PRs that change backend components
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants