-
Notifications
You must be signed in to change notification settings - Fork 6
feat: add filter fields to WorkItemQueryParams #24
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -1,6 +1,6 @@ | ||||||
| """Query parameter DTOs for list/retrieve endpoints.""" | ||||||
|
|
||||||
| from pydantic import BaseModel, ConfigDict, Field | ||||||
| from pydantic import BaseModel, ConfigDict, Field, model_serializer | ||||||
|
|
||||||
|
|
||||||
| class BaseQueryParams(BaseModel): | ||||||
|
|
@@ -62,6 +62,48 @@ class WorkItemQueryParams(PaginatedQueryParams): | |||||
|
|
||||||
| model_config = ConfigDict(extra="ignore", populate_by_name=True) | ||||||
|
|
||||||
| assignee_id__in: list[str] | None = Field( | ||||||
| None, | ||||||
| description="Filter by assignee UUIDs", | ||||||
| ) | ||||||
| state_id__in: list[str] | None = Field( | ||||||
| None, | ||||||
| description="Filter by state UUIDs", | ||||||
| ) | ||||||
| state_group__in: list[str] | None = Field( | ||||||
| None, | ||||||
| description="Filter by state groups (backlog, unstarted, started, completed, cancelled)", | ||||||
| ) | ||||||
| priority__in: list[str] | None = Field( | ||||||
| None, | ||||||
| description="Filter by priority levels (urgent, high, medium, low, none)", | ||||||
| ) | ||||||
| label_id__in: list[str] | None = Field( | ||||||
| None, | ||||||
| description="Filter by label UUIDs", | ||||||
| ) | ||||||
| created_by_id__in: list[str] | None = Field( | ||||||
| None, | ||||||
| description="Filter by creator user UUIDs", | ||||||
| ) | ||||||
| is_draft: bool | None = Field( | ||||||
| None, | ||||||
| description="Filter by draft status", | ||||||
| ) | ||||||
| is_archived: bool | None = Field( | ||||||
| None, | ||||||
| description="Filter by archived status", | ||||||
| ) | ||||||
|
|
||||||
| @model_serializer(mode="wrap") | ||||||
| def _serialize(self, handler): # type: ignore[no-untyped-def] | ||||||
| """Serialize list fields as comma-separated strings for django-filters.""" | ||||||
|
Comment on lines
+98
to
+100
|
||||||
| data = handler(self) | ||||||
| for key, value in data.items(): | ||||||
| if isinstance(value, list): | ||||||
|
||||||
| if isinstance(value, list): | |
| if key.endswith("__in") and isinstance(value, list): |
Copilot
AI
Mar 23, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
New serialization behavior (converting list filters to comma-separated strings) isn’t covered by tests. Please add a unit test that asserts WorkItemQueryParams(assignee_id__in=[...]).model_dump(exclude_none=True) produces a comma-separated string, since this behavior is critical for server-side filtering to work with requests query encoding.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
state_group__inandpriority__inare typed aslist[str], but the codebase already defines constrained Literal types (GroupEnum,PriorityEnum) used across models. Consider typing these aslist[GroupEnum] | Noneandlist[PriorityEnum] | Noneto prevent invalid values at compile/validation time and keep consistency with the rest of the SDK.