Skip to content

Commit

Permalink
Separate function for storing data
Browse files Browse the repository at this point in the history
  • Loading branch information
vg12345 committed Sep 30, 2024
1 parent edb2358 commit 58891e9
Showing 1 changed file with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,15 @@ def get_telemetry(self):
telemetry_data = None

# store telemetry data
self.store_telemetry_data(telemetry_data)

# return retrieved data
return telemetry_data

def store_telemetry_data(self, telemetry_data):
"""
Store telemetry data into the file
"""
try:
if self.previous_telemetry_data is not None and telemetry_data is not None:
delta = self._get_delta(self.previous_telemetry_data,telemetry_data)
Expand All @@ -48,10 +57,9 @@ def get_telemetry(self):
except Exception as exception_error: # pylint: disable=broad-exception-caught
self.logger.error(f"Failed to store telemetry data with error {exception_error}")

# update previous telemetry data
# keep telemetry data for next delta calculation
if telemetry_data is not None:
self.previous_telemetry_data = telemetry_data
return telemetry_data

def _get_delta(self, first_df: pd.DataFrame, second_df:pd.DataFrame):
merged_df = pd.merge(second_df, first_df, on=self.BASED_COLUMNS, how='inner', suffixes=('', '_x'))
Expand Down

0 comments on commit 58891e9

Please sign in to comment.