Skip to content

Commit

Permalink
fix the marker color on the sensor page
Browse files Browse the repository at this point in the history
  • Loading branch information
danieltsoukup committed Sep 22, 2024
1 parent 21d2aee commit c573400
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions app/src/data_loading/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,17 +150,26 @@ def get_label(self, location_id: str) -> int:

return label

def _get_active_time_limit(self) -> datetime:
"""
Get the current threshold for marking sensor as active.
"""
limit = pd.Timestamp("now") + pd.Timedelta(-4, unit="H")
limit += pd.Timedelta(-1, unit="H")

return limit

def get_active_status(self, location_id: str) -> int:
"""
Return the activity status for the device.
"""
if self.location_info is None:
self.load_and_format_location_info(location_id=location_id)
if self.location_stats is None:
self.load_and_format_location_stats(location_id=location_id)

info = self.location_info.to_dict("records")[0]
active = info[COLUMN.ACTIVE]
stats = self.location_stats.to_dict("records")[0]
limit = self._get_active_time_limit()

return active
return stats[COLUMN.END] > limit

def load_and_format_locations(self):
"""
Expand Down Expand Up @@ -195,8 +204,7 @@ def attach_all_location_stats(self) -> None:
stats = pd.concat(stats, axis=0, ignore_index=True)

# add sending data flag
limit = pd.Timestamp("now") + pd.Timedelta(-4, unit="H")
limit += pd.Timedelta(-1, unit="H")
limit = self._get_active_time_limit()
stats[COLUMN.SENDING_DATA] = stats[COLUMN.END] > limit

self.locations = pd.concat([self.locations, stats], axis=1)
Expand Down

0 comments on commit c573400

Please sign in to comment.