refactor: structured query params (conditions + sorting) for tasks API#186
Open
refactor: structured query params (conditions + sorting) for tasks API#186
Conversation
…ks API Replace ad-hoc filter query params (project_id, assignee_ids, tag_ids, etc.) with a structured JSON `conditions` parameter using FilterCondition[]. Replace JSON-encoded `sorting` parameter with simple `sort_by`/`sort_dir` string params since the UI only sorts by one column at a time. Backend: add query parsing utilities (parse_conditions, parse_sort_fields), OpenAPI schema injection for FilterCondition/SortField types, and automatic date_group→due_date secondary sort expansion. Frontend: update all task list consumers (global tasks, created tasks, tag tasks, dashboard, project tasks) to use structured conditions and simple sort params. Update paramsSerializer to JSON-encode object arrays.
Contributor
Greptile SummaryReplaces ad-hoc task filtering query parameters with a structured JSON Key improvements:
Confidence Score: 5/5
Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[Frontend: Task List Component] -->|FilterCondition array| B[API Client paramsSerializer]
B -->|JSON.stringify for object arrays| C[HTTP Request with conditions param]
C --> D[Backend: list_tasks endpoint]
D -->|parse_conditions| E[query.py: Security validation]
E -->|Size limits, field count limits| F[FilterCondition objects]
F -->|_build_task_filter_fields| G[Allowed fields dict with callables]
G -->|apply_filters| H[SQLAlchemy WHERE clauses]
D -->|sort_by/sort_dir strings| I[query.py: apply_sorting]
I -->|date_group auto-expands| J[SortField list]
J -->|TASK_SORT_FIELDS mapping| K[SQLAlchemy ORDER BY clauses]
H --> L[Base query with filters]
K --> L
L -->|paginated_query| M[Count + Data queries]
M -->|_clamp_page| N[TaskListResponse]
N -->|build_paginated_response| O[JSON response]
O --> P[Frontend: Typed FilterCondition/SortField]
Q[OpenAPI Schema Injection] -->|_inject_query_schemas| R[Orval TypeScript generation]
R --> P
Last reviewed commit: 52df4bf |
…g param Swap simple sort_by/sort_dir string params for a JSON-encoded sorting param using SortField[] — the same pattern as conditions/FilterCondition[]. Enables multi-column sorting (e.g. date_group then due_date).
jordandrako
requested changes
Feb 23, 2026
Comment on lines
+183
to
+184
| "QUERY_INVALID_CONDITIONS": "Invalid filter conditions", | ||
| "QUERY_INVALID_SORT_FIELDS": "Invalid sort fields", |
Member
There was a problem hiding this comment.
Ensure we also update locales/es translations
…parse - Update task.factory.ts: replace sort_by/sort_dir with sorting, add has_prev - Add QUERY_INVALID_CONDITIONS and QUERY_INVALID_SORT_FIELDS to es/errors.json - Add defensive `or None` to parse_sort_fields in case of empty list
Tests were still using old-style query params (assignee_ids, priorities, guild_ids, project_id, task_status_ids) which the endpoint no longer accepts. Migrate to the structured conditions JSON format.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Summary
project_id,assignee_ids,tag_ids, etc.) with a structured JSONconditionsparameter usingFilterCondition[]sort_by/sort_dirstring params with a structured JSONsortingparameter usingSortField[]— enables multi-column sorting (e.g. date_group then due_date)parse_conditions,parse_sort_fields) with security hardening (size limits, field count limits, JSON validation)conditionsandsortingfollow the same pattern: JSON-encoded arrays of objects, auto-serialized by the AxiosparamsSerializerNotable changes
Backend:
app/db/query.py— centralized query utilities for filtering, sorting, and paginationapp/schemas/query.py—FilterCondition,SortField,FilterOp,SortDirschemastasks.pyendpoint usesparse_sort_fields()to parse thesortingJSON paramTaskListResponseschema:sort_by/sort_dir→sortingconditions(FilterCondition[]) andsorting(SortField[]) so Orval auto-generates correct TypeScript typesFrontend:
useGlobalTasksTable—SortField[]state replacessortBy/sortDirstrings;handleSortingChangemapsSortingState→SortField[]with auto secondary sort fordate_groupTagTasksTable— same pattern withSortField[]GuildDashboardPage— dashboard task params usesorting: [{ field: "due_date", dir: "asc" }]index.tsx,created-tasks.tsx) — usesorting: JSON.stringify(defaultSorting)ListTasksApiV1TasksGetParams.sortingisSortField[]Test plan
ruff check— lint cleanpytest app/db/query_test.py— 96 tests pass (includesTestParseSortFieldsandTestParseConditions)ListTasksApiV1TasksGetParamshassorting?: SortField[]npx tsc --noEmit— frontend compiles with no errors