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

Conversation

@metroid-samus
Copy link
Contributor

@metroid-samus metroid-samus commented Mar 10, 2025

This PR implements the classic cost model functionality for cases, mirroring the existing incident cost model while adapting for case-specific concepts.

Changes

Core Implementation

Added role-based engagement multipliers for case roles:

  • Assignee: 1.0 (equivalent to incident commander)
  • Reporter: 0.5
  • Participant: 0.5
  • Observer: 0 (no cost calculation)

Implemented time calculation functions that handle case status transitions:

  • New/Triage: Active time tracking
  • Closed: Cost calculation stops at closed_at
  • Escalated: Cost calculation stops at escalated_at

Cost Calculation

  • Both cost models (new and classic) now run in parallel
  • Results are returned as a dictionary with both cost calculations
  • Time calculations account for 8-hour workdays when cases extend beyond 24 hours

Testing

The implementation includes tests for:

  • Role engagement multiplier accuracy
  • Time calculation edge cases
  • Cost calculation verification
  • Classic Cost Model integration
  • Status transition handling

Migration

No migration required. The classic model will begin calculating costs for cases automatically while maintaining the existing new model calculations.

UI

  • The Case Dashboard now includes total case costs using both the Classic Cost Model and New Cost Model
Screenshot 2025-03-11 at 4 24 27 PM
  • The case costs tab allows the user to toggle between the costs reported by each type of cost model.
Screenshot 2025-03-11 at 4 24 15 PM Screenshot 2025-03-11 at 4 23 59 PM

Related PR: #5800

@metroid-samus metroid-samus self-assigned this Mar 10, 2025
@metroid-samus metroid-samus added the enhancement New feature or request label Mar 10, 2025
@metroid-samus metroid-samus requested a review from wssheldon March 10, 2025 22:52
@metroid-samus metroid-samus marked this pull request as ready for review March 11, 2025 23:40
@metroid-samus metroid-samus requested a review from whitdog47 March 11, 2025 23:40
@metroid-samus metroid-samus merged commit 14fc66b into main Mar 12, 2025
10 checks passed
@metroid-samus metroid-samus deleted the enhancement/parallel-case-cost-model-calculation branch March 12, 2025 18:25
Comment on lines +203 to 220
def total_cost_classic(self):
total_cost = 0
if self.case_costs:
for cost in self.case_costs:
if cost.case_cost_type.model_type == CostModelType.new:
continue
total_cost += cost.amount
return total_cost

@hybrid_property
def total_cost_new(self):
total_cost = 0
if self.case_costs:
for cost in self.case_costs:
if cost.case_cost_type.model_type == CostModelType.classic:
continue
total_cost += cost.amount
return total_cost
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: could fail fast here to reduce nesting and improve readability

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants