Skip to content

🐛 Bug: Profile sidebar assigned count includes stale soft-deleted assignees #8868

@GLDRoger

Description

@GLDRoger

Summary

The user profile page can show inconsistent assigned-work-item counts between the overview cards and the project sidebar breakdown.

Affected area

  • Profile overview cards
  • /[workspaceSlug]/profile/[userId]/assigned
  • Backend endpoint: WorkspaceUserProfileEndpoint

Symptoms

A user can see:

  • Work items assigned = 1 in the overview cards
  • but Assigned = 3 Work items in the profile sidebar/project summary

This happens when the user used to be assigned to additional work items, but those assignee relations were later removed.

Minimal reproduction

  1. Create a user and assign them to 3 work items in the same project.
  2. Remove the user from 2 of those work items so the corresponding IssueAssignee rows are soft-deleted.
  3. Open the user's profile overview and assigned tab.
  4. Observe:
    • the overview cards correctly show 1 assigned work item
    • the project sidebar breakdown can still show 3 assigned work items

Root cause

WorkspaceUserProfileEndpoint currently aggregates project counts with filters like:

  • project_issue__assignees__in=[user_id]

That can include stale rows from the IssueAssignee through table when older assignee records were soft-deleted.

Other profile count paths already guard against this by filtering active assignee relations with:

  • issue_assignee__deleted_at__isnull=True

So the profile sidebar can drift from the overview counts.

Expected behavior

Project-level assigned/completed/pending counts on the profile sidebar should only count active assignee relations.

Suggested fix

In WorkspaceUserProfileEndpoint, count assigned-related aggregates via active IssueAssignee rows instead of the raw M2M relation, for example:

  • project_issue__issue_assignee__assignee_id=user_id
  • project_issue__issue_assignee__deleted_at__isnull=True
  • distinct=True

Regression coverage

A regression test should cover:

  1. one active assignment
  2. two historical assignments whose IssueAssignee.deleted_at is set
  3. sidebar endpoint returns assigned_issues == 1, not 3

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions