Skip to content

feat(case): adds stable status to cases #6074

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

whitdog47
Copy link
Contributor

@whitdog47 whitdog47 commented Jun 20, 2025

NOTE: This PR must be merged after #6073 due to db migration conflicts

This PR adds comprehensive support for the "Stable" status to cases, mirroring the existing functionality for incidents. This includes database schema changes, backend logic updates, frontend UI improvements, and cost calculation modifications.

Key Changes

Database & Backend

  • Database Migration: Added stable_at timestamp column to the case table
  • Case Model: Updated Case and CaseReadMinimal models to include stable_at field
  • Status Transitions: Added status transition flows for Stable state
  • Case Service: Enhanced get_all_by_status to include stable cases and added get_all_last_x_hours_by_status for stable cases
  • Cost Calculation: Modified case cost calculation logic to stop at stable_at time, similar to incident cost behavior

Frontend UI

  • Status Selector: Updated CaseStatusSelectGroup.vue to include "Stable" status with proper ordering and visual indicators
  • Case Details: Added stable_at timestamp display in case details tab
  • Dashboard: Enhanced case overview to show total stable cases count
  • Export: Added "Stable At" field to CSV export functionality
  • Filtering: Updated case filters to include stable_at field

Cost Calculation Logic

  • Scheduled Tasks: Modified calculate_cases_response_cost to include stable cases and stop cost updates after stable_at
  • Time Calculation: Updated get_participant_role_time_seconds to:
    • Handle timezone-aware datetime comparisons
    • Apply engagement multipliers based on participant roles
    • Stop time calculation at stable_at for stable cases
    • Return 0 for observer roles
  • Cost Models: Both classic and new cost models now respect the stable_at timestamp

Testing

  • Comprehensive Test Coverage: Added new test test_case_cost_stops_at_stable_time to verify stable case cost behavior
  • Fixed Existing Tests: Resolved timezone comparison issues in case cost service tests

Screenshots

image image

@whitdog47 whitdog47 requested a review from Copilot June 20, 2025 22:42
@whitdog47 whitdog47 self-assigned this Jun 20, 2025
@whitdog47 whitdog47 added the enhancement New feature or request label Jun 20, 2025
@whitdog47 whitdog47 changed the title Feat/add stable status to cases feat(case): adds stable status to cases Jun 20, 2025
Copy link
Contributor

@Copilot 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

Adds full support for a new “Stable” status on cases by extending the database schema, back-end logic, front-end UI, cost calculations, and notifications.

  • Database & Models: Introduces stable_at timestamp across SQL models, Pydantic schemas, and Alembic migration
  • Cost Logic & Tests: Updates cost calculation to halt at stable_at, and adds test_case_cost_stops_at_stable_time
  • UI & Messaging: Integrates Stable status into selectors, filters, exports, dashboards, and reminder flows

Reviewed Changes

Copilot reviewed 20 out of 21 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/dispatch/database/revisions/tenant/versions/*.py Adds stable_at column migration
src/dispatch/case_cost/service.py Enhances time-cutoff logic in cost service
src/dispatch/static/dispatch/src/dashboard/case/CaseOverview.vue Displays total stable cases on dashboard
src/dispatch/static/dispatch/src/case/CaseStatusSelectGroup.vue Inserts “Stable” option in status selector
src/dispatch/case/flows.py Implements new create & transition flows for Stable
tests/case_cost/test_case_cost_service.py Adds test to verify cost stops at stable_at
Comments suppressed due to low confidence (2)

src/dispatch/case/flows.py:353

  • In the escalation creation flow, the case is marked as Stable before the escalation transition. This ordering is likely incorrect—Stable should not be set during an escalate flow. Please remove or relocate this call.
    case_stable_status_flow(case=case, db_session=db_session)

src/dispatch/static/dispatch/src/case/DetailsTab.vue:138

  • [nitpick] The added Stable date picker appears to close the <v-row>/<v-col> wrappers prematurely, which can break the layout of subsequent fields. Please verify and correct the nesting of those tags.
        </v-row>

Co-authored-by: Copilot <[email protected]>
Signed-off-by: David Whittaker <[email protected]>
@whitdog47 whitdog47 requested a review from aaronherman June 20, 2025 22:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant