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

New smart API to list issues #2534

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
Open

Conversation

vrigal
Copy link
Collaborator

@vrigal vrigal commented Nov 22, 2024

Based on #2530 (merged)

Closes #2533

All issues that are not returned as known/closed/unresolved can be considered as new.

@vrigal vrigal requested a review from La0 November 22, 2024 16:56
@vrigal
Copy link
Collaborator Author

vrigal commented Nov 26, 2024

I noticed the same combination of (analyzer, level, check, message) may be reported multiple times per file, which would lead to inconsistent returned values. For example, a new issues could be reported as known (if a similar issue is known on this file) or an issue could be returned as both unresolved and closed (in case there are multiple similar issues on a file, and only one has been closed).

I think we should keep this endpoint KISS, and handle such edge cases in the bot.

@vrigal vrigal marked this pull request as ready for review November 26, 2024 11:50
Copy link
Collaborator

@La0 La0 left a comment

Choose a reason for hiding this comment

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

A few comments to address as discussed together.

Then we'll run it on a local prod dump, and can probably ship to testing as it adds new endpoints.

self.diff.issue_links.annotate(
known=Exists(
IssueLink.objects.filter(
revision__base_repository__slug="mozilla-central",
Copy link
Collaborator

Choose a reason for hiding this comment

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

You can use the curent diff base repository id to make the query generic & faster (one less join)

Suggested change
revision__base_repository__slug="mozilla-central",
revision__base_repository_id=self.diff.revision.base_repository_id,

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

revision__base_repository_id=self.diff.revision.base_repository_id do includes all issues from all diffs with the base repository. I suppose it should match revision__head_repository_id instead ?

backend/code_review_backend/issues/api_v2.py Outdated Show resolved Hide resolved
backend/code_review_backend/issues/api_v2.py Outdated Show resolved Hide resolved
backend/code_review_backend/issues/api_v2.py Outdated Show resolved Hide resolved
backend/code_review_backend/issues/api_v2.py Outdated Show resolved Hide resolved
@La0
Copy link
Collaborator

La0 commented Dec 6, 2024

You will also need to serialize the previous_diff_id when applicable (on unresolved & closed issues).

This does not invalidate the fact that a 400 should be raised when it's not present in these cases

@vrigal vrigal requested a review from La0 December 6, 2024 16:58
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.

New API endpoint to list issues
2 participants