From a48c33eda873e596d5922f874a50b23c7415e0c4 Mon Sep 17 00:00:00 2001
From: Athanasius <github@miggy.org>
Date: Wed, 25 Aug 2021 13:45:42 +0100
Subject: [PATCH] companion: Change record_endpoint() query_time to mandatory

This *does* need to be generated as close as possible to where the data
was received, and not rely on an actually not dynamic default.
---
 companion.py | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/companion.py b/companion.py
index 5528262c..fe112f5a 100644
--- a/companion.py
+++ b/companion.py
@@ -150,7 +150,7 @@ class CAPIDataRaw:
     def record_endpoint(
             self, endpoint: str,
             raw_data: str,
-            query_time: datetime.datetime = datetime.datetime.utcnow()
+            query_time: datetime.datetime
     ):
         """Record the latest raw data for the given endpoint."""
         self.raw_data[endpoint] = CAPIDataRawEndpoint(raw_data, query_time)
@@ -740,7 +740,10 @@ class Session(object):
                 # May also fail here if token expired since response is empty
                 capi_json = r.json()
                 capi_data = CAPIData(capi_json, capi_endpoint)
-                self.capi_raw_data.record_endpoint(capi_endpoint, r.content.decode(encoding='utf-8'))
+                self.capi_raw_data.record_endpoint(
+                    capi_endpoint, r.content.decode(encoding='utf-8'),
+                    datetime.datetime.utcnow()
+                )
 
             except requests.ConnectionError as e:
                 logger.warning(f'Unable to resolve name for CAPI: {e} (for request: {capi_endpoint})')