Skip to content
Merged
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 backend/prompt_studio/prompt_studio_core_v2/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ def get_queryset(self) -> QuerySet | None:
ToolStudioPrompt.objects.filter(tool_id=OuterRef("pk"))
.order_by()
.values("tool_id")
.annotate(cnt=Count("id"))
.annotate(cnt=Count("prompt_id"))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2 Consider using Count("*") for clarity

The fix is correct — prompt_id is the non-null primary key so Count("prompt_id") is semantically identical to COUNT(*). However, using Count("*") makes the intent explicit ("count every row in the group") and avoids any future confusion if a reader wonders why a specific field is named here rather than a simple row count.

Suggested change
.annotate(cnt=Count("prompt_id"))
.annotate(cnt=Count("*"))
Prompt To Fix With AI
This is a comment left during a code review.
Path: backend/prompt_studio/prompt_studio_core_v2/views.py
Line: 118

Comment:
**Consider using `Count("*")` for clarity**

The fix is correct — `prompt_id` is the non-null primary key so `Count("prompt_id")` is semantically identical to `COUNT(*)`. However, using `Count("*")` makes the intent explicit ("count every row in the group") and avoids any future confusion if a reader wonders why a specific field is named here rather than a simple row count.

```suggestion
                .annotate(cnt=Count("*"))
```

How can I resolve this? If you propose a fix, please make it concise.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

.values("cnt")
)
qs = qs.select_related("created_by").annotate(
Expand Down