Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/worker/services/test_analytics/ta_process_flakes.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def get_relevant_uploads(repo_id: int, commit_id: str) -> QuerySet[ReportSession
report__commit__repository__repoid=repo_id,
report__commit__commitid=commit_id,
state__in=["processed"],
)
).select_related("report__commit__repository__author")

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Bug: The get_relevant_uploads query includes an unnecessary .select_related() for the author field, which is never accessed in the flake processing logic, causing a needless database JOIN.
Severity: LOW

Suggested Fix

Remove report__commit__repository__author from the .select_related() call within the get_relevant_uploads function, as the author field is not used by the caller.

Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent. Verify if this is a real issue. If it is, propose a fix; if not, explain why it's
not valid.

Location: apps/worker/services/test_analytics/ta_process_flakes.py#L28

Potential issue: The query in `get_relevant_uploads` was modified to include
`.select_related("report__commit__repository__author")` to pre-fetch the repository's
author. However, the subsequent processing logic in `process_single_upload` never
accesses the `author` field. This results in an unnecessary JOIN operation on the
database every time flakes are processed for a repository. While the performance impact
is minor for a background task, it introduces needless database load.

Did we get this right? 👍 / 👎 to inform future reviews.


def fetch_current_flakes(repo_id: int) -> dict[bytes, Flake]:
Expand Down
Loading