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

Conversation

@wssheldon
Copy link
Contributor

No description provided.

@wssheldon wssheldon self-assigned this Jun 23, 2025
@wssheldon wssheldon added the enhancement New feature or request label Jun 23, 2025
Copy link
Contributor

Copilot AI left a comment

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
Copy link

Copilot AI Jun 23, 2025

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):
Copy link

Copilot AI Jun 23, 2025

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]
Copy link

Copilot AI Jun 23, 2025

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
Copy link

Copilot AI Jun 23, 2025

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
Copy link
Contributor

github-actions bot commented Aug 9, 2025

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
@wssheldon wssheldon closed this Aug 9, 2025
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.

2 participants