@@ -146,11 +146,9 @@ def update_incident_response_cost_for_incident_type(
146
146
147
147
def calculate_response_cost (
148
148
hourly_rate , total_response_time_seconds , incident_review_hours = 0
149
- ) -> int :
150
- """Calculates and rounds up the incident response cost."""
151
- return math .ceil (
152
- ((total_response_time_seconds / SECONDS_IN_HOUR ) + incident_review_hours ) * hourly_rate
153
- )
149
+ ) -> float :
150
+ """Calculates the incident response cost."""
151
+ return ((total_response_time_seconds / SECONDS_IN_HOUR ) + incident_review_hours ) * hourly_rate
154
152
155
153
156
154
def get_default_incident_response_cost (
@@ -235,7 +233,7 @@ def fetch_incident_events(
235
233
236
234
def calculate_incident_response_cost_with_cost_model (
237
235
incident : Incident , db_session : SessionLocal
238
- ) -> int :
236
+ ) -> float :
239
237
"""Calculates the cost of an incident using the incident's cost model.
240
238
241
239
This function aggregates all new incident costs based on plugin activity since the last incident cost update.
@@ -246,7 +244,7 @@ def calculate_incident_response_cost_with_cost_model(
246
244
db_session: The database session.
247
245
248
246
Returns:
249
- int : The incident response cost in dollars.
247
+ float : The incident response cost in dollars.
250
248
"""
251
249
252
250
participants_total_response_time_seconds = 0
@@ -304,12 +302,12 @@ def calculate_incident_response_cost_with_cost_model(
304
302
total_response_time_seconds = participants_total_response_time_seconds ,
305
303
)
306
304
307
- return incident .total_cost + amount
305
+ return float ( incident .total_cost ) + amount
308
306
309
307
310
308
def get_participant_role_time_seconds (
311
309
incident : Incident , participant_role : ParticipantRole , start_at : datetime
312
- ) -> int :
310
+ ) -> float :
313
311
"""Calculates the time spent by a participant in an incident role starting from a given time.
314
312
315
313
The participant's time spent in the incident role is adjusted based on the role's engagement multiplier.
@@ -320,7 +318,7 @@ def get_participant_role_time_seconds(
320
318
start_at: Only time spent after this will be considered.
321
319
322
320
Returns:
323
- int : The time spent by the participant in the incident role in seconds.
321
+ float : The time spent by the participant in the incident role in seconds.
324
322
"""
325
323
if participant_role .renounced_at and participant_role .renounced_at < start_at :
326
324
# skip calculating already-recorded activity
@@ -372,7 +370,7 @@ def get_participant_role_time_seconds(
372
370
# TODO(mvilanova): adjust based on incident priority
373
371
if participant_role_time_hours > HOURS_IN_DAY :
374
372
days , hours = divmod (participant_role_time_hours , HOURS_IN_DAY )
375
- participant_role_time_hours = math . ceil ((( days * HOURS_IN_DAY ) / 3 ) + hours )
373
+ participant_role_time_hours = (( days * HOURS_IN_DAY ) / 3 ) + hours
376
374
377
375
# we make the assumption that participants spend more or less time based on their role
378
376
# and we adjust the time spent based on that
@@ -410,7 +408,7 @@ def get_total_participant_roles_time_seconds(incident: Incident, start_at: datet
410
408
411
409
def calculate_incident_response_cost_with_classic_model (
412
410
incident : Incident , db_session : SessionLocal , incident_review : bool = False
413
- ) -> int :
411
+ ) -> float :
414
412
"""Calculates the cost of an incident using the classic incident cost model.
415
413
416
414
This function aggregates all new incident costs since the last incident cost update. If this is the first time performing cost calculation for this incident, it computes the total costs from the incident's creation.
@@ -421,7 +419,7 @@ def calculate_incident_response_cost_with_classic_model(
421
419
incident_review: Whether to add the incident review costs in this calculation.
422
420
423
421
Returns:
424
- int : The incident response cost in dollars.
422
+ float : The incident response cost in dollars.
425
423
"""
426
424
last_update = incident .created_at
427
425
incident_review_hours = 0
@@ -456,7 +454,7 @@ def calculate_incident_response_cost_with_classic_model(
456
454
incident_review_hours = incident_review_hours ,
457
455
)
458
456
459
- return incident_response_cost .amount + amount
457
+ return float ( incident_response_cost .amount ) + amount
460
458
461
459
462
460
def calculate_incident_response_cost (
0 commit comments