Skip to content
This repository was archived by the owner on Sep 3, 2025. It is now read-only.

refactor(case): main table to use fastapi-filters#6082

Closed
ghost wants to merge 3 commits into
mainfrom
refactor/fastapi-filters-case
Closed

refactor(case): main table to use fastapi-filters#6082
ghost wants to merge 3 commits into
mainfrom
refactor/fastapi-filters-case

Conversation

@ghost

@ghost ghost commented Jun 23, 2025

Copy link
Copy Markdown

No description provided.

@ghost ghost requested review from aaronherman, Copilot and mvilanova June 23, 2025 23:36
@ghost ghost self-assigned this Jun 23, 2025
@ghost ghost added the enhancement New feature or request label Jun 23, 2025

Copilot AI left a comment

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.

Pull Request Overview

This PR refactors both frontend and backend to leverage FastAPI-Filter for case list filtering and sorting, replacing custom parameter builders with standardized filters.

  • Added client-side utilities (createFastAPIFilterParameters, createFastAPIFilterParams) to generate FastAPI-filter query parameters.
  • Updated Vuex store action to use the new FastAPI-filter parameter helper.
  • Refactored the backend get_cases endpoint to use CaseFilter, FilterDepends, and new pagination JSON methods.
  • Introduced CaseFilter and auxiliary filter classes; updated dependency pins and VSCode formatter settings.

Reviewed Changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
src/dispatch/static/dispatch/src/search/utils.js Added FastAPI-filter parameter builders for client-side filtering and sorting.
src/dispatch/static/dispatch/src/case/store.js Switched store action to use createFastAPIFilterParameters.
src/dispatch/case/views.py Refactored get_cases to use CaseFilter, FilterDepends, and model_dump_json.
src/dispatch/case/filters.py Added CaseFilter and related filter classes for backend filtering logic.
requirements-base.txt & requirements-base.in Added fastapi-filter, advanced-alchemy; bumped sqlalchemy version.
.vscode/settings.json Updated Python formatter and Ruff code-action settings.

from fastapi_filter.contrib.sqlalchemy import Filter
from pydantic import Field
from sqlalchemy.orm import Query
from sqlalchemy.orm.query import Query

Copilot AI Jun 23, 2025

Copy link

Choose a reason for hiding this comment

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

Duplicate import of Query; remove the redundant import on this line to clean up dependencies.

Suggested change
from sqlalchemy.orm.query import Query

Copilot uses AI. Check for mistakes.


# Alternative approach using separate filters for different concerns
class CaseBasicFilter(Filter):

Copilot AI Jun 23, 2025

Copy link

Choose a reason for hiding this comment

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

[nitpick] These alternative filter classes (e.g., CaseBasicFilter, CaseStatusFilter, etc.) are not referenced in the PR; consider moving them to a separate module or removing unused code to improve maintainability.

Copilot uses AI. Check for mistakes.

// Add sorting parameters
if (sortBy && sortBy.length > 0) {
params.order_by = descending[0] ? `-${sortBy[0]}` : sortBy[0]

Copilot AI Jun 23, 2025

Copy link

Choose a reason for hiding this comment

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

[nitpick] Currently only the first sortBy field is applied (order_by = sortBy[0]); if multi-column sorting is required, consider iterating over all fields or explicitly documenting that only the primary sort is supported.

Suggested change
params.order_by = descending[0] ? `-${sortBy[0]}` : sortBy[0]
params.order_by = sortBy.map((field, index) =>
descending[index] ? `-${field}` : field
).join(",");

Copilot uses AI. Check for mistakes.
"""Retrieves all cases."""
pagination = search_filter_sort_paginate(model="Case", **common)
"""Retrieves all cases using FastAPI-Filter."""
import json

Copilot AI Jun 23, 2025

Copy link

Choose a reason for hiding this comment

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

Move the import json statement to the top of the file with other imports to keep import statements organized.

Suggested change
import json
# json module is used for serialization/deserialization

Copilot uses AI. Check for mistakes.
@github-actions

github-actions Bot commented Aug 9, 2025

Copy link
Copy Markdown
Contributor

This PR is stale, because it has been open for 45 days with no activity. Remove the stale label or comment, or this will be closed in 10 days.

@github-actions github-actions Bot added the Stale label Aug 9, 2025
@ghost ghost closed this Aug 9, 2025
This pull request was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

enhancement New feature or request Stale

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant