From ae6a449d1382e3312c39169894c576052977f93f Mon Sep 17 00:00:00 2001 From: Furkan Date: Wed, 4 Dec 2024 21:27:58 +0300 Subject: [PATCH] fix: fix DAQJobHandleStats not combining data --- src/enrgdaq/daq/jobs/handle_stats.py | 36 ++++++++++++++-------------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/src/enrgdaq/daq/jobs/handle_stats.py b/src/enrgdaq/daq/jobs/handle_stats.py index 7dce295..ea7b245 100644 --- a/src/enrgdaq/daq/jobs/handle_stats.py +++ b/src/enrgdaq/daq/jobs/handle_stats.py @@ -65,6 +65,17 @@ def handle_message(self, message: DAQJobMessageStats) -> bool: return True def _save_stats(self): + def datetime_to_str(dt: Optional[datetime]): + if dt is None: + return "N/A" + return get_unix_timestamp_ms(dt) + + def unpack_record(record: DAQJobStatsRecord): + return [ + datetime_to_str(record.last_updated), + record.count, + ] + keys = [ "supervisor", "daq_job", @@ -76,20 +87,9 @@ def _save_stats(self): "last_restart_date", "restart_count", ] - - def datetime_to_str(dt: Optional[datetime]): - if dt is None: - return "N/A" - return get_unix_timestamp_ms(dt) - - def unpack_record(record: DAQJobStatsRecord): - return [ - datetime_to_str(record.last_updated), - record.count, - ] + data_to_send = [] for supervisor_id, stats in self._stats.items(): - data_to_send = [] for daq_job_type, msg in stats.items(): data_to_send.append( [ @@ -102,10 +102,10 @@ def unpack_record(record: DAQJobStatsRecord): ] ) - self._put_message_out( - DAQJobMessageStoreTabular( - store_config=self.config.store_config, - keys=keys, - data=data_to_send, - ) + self._put_message_out( + DAQJobMessageStoreTabular( + store_config=self.config.store_config, + keys=keys, + data=data_to_send, ) + )