From 3f4bc7d46fa374c7097948ed47d0bf0a7dac4074 Mon Sep 17 00:00:00 2001
From: adamfilipow92 <64852261+adamfilipow92@users.noreply.github.com>
Date: Mon, 12 Jul 2021 13:16:35 +0200
Subject: [PATCH] fix: Fix calculating total test cost in Mixpanel (#2084)

Fixes #

## Test Plan
> How do we know the code works?

In mixpanel ```devices_cost. total_cost ``` event should be the sum of virtual cost and physical cost instead of the sum of physical and virtual minutes
---
 .../src/main/kotlin/ftl/reports/CostReport.kt       | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/test_runner/src/main/kotlin/ftl/reports/CostReport.kt b/test_runner/src/main/kotlin/ftl/reports/CostReport.kt
index 205b8c43a0..3bf86c2c83 100644
--- a/test_runner/src/main/kotlin/ftl/reports/CostReport.kt
+++ b/test_runner/src/main/kotlin/ftl/reports/CostReport.kt
@@ -28,13 +28,16 @@ object CostReport : IReport {
             totalBillablePhysicalMinutes += it.billableMinutes.physical
         }
 
+        val virtualCost = calculateVirtualCost(totalBillableVirtualMinutes.toBigDecimal())
+        val physicalCost = calculatePhysicalCost(totalBillablePhysicalMinutes.toBigDecimal())
+
         args.sendConfiguration(
             events = mapOf(
-                "virtual_cost" to calculateVirtualCost(totalBillableVirtualMinutes.toBigDecimal()),
-                "physical_cost" to calculatePhysicalCost(totalBillablePhysicalMinutes.toBigDecimal()),
-                "total_cost" to calculateTotalCost(
-                    totalBillablePhysicalMinutes.toBigDecimal(),
-                    totalBillableVirtualMinutes.toBigDecimal()
+                "virtual_cost" to virtualCost,
+                "physical_cost" to physicalCost,
+                "cost_total" to calculateTotalCost(
+                    virtualCost,
+                    physicalCost
                 )
             ),
             eventName = "devices_cost"