Skip to content

Commit

Permalink
fix: fix DAQJobHandleStats not combining data
Browse files Browse the repository at this point in the history
  • Loading branch information
furkan-bilgin committed Dec 4, 2024
1 parent b26cb36 commit ae6a449
Showing 1 changed file with 18 additions and 18 deletions.
36 changes: 18 additions & 18 deletions src/enrgdaq/daq/jobs/handle_stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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(
[
Expand All @@ -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,
)
)

0 comments on commit ae6a449

Please sign in to comment.