Skip to content

Commit

Permalink
Daily Summary: Explicitly handle cases of 0
Browse files Browse the repository at this point in the history
Fixes #46
Fixes #49
  • Loading branch information
martomi committed Apr 27, 2021
1 parent 357fc22 commit 5ceedf8
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,6 @@ def consume(self, obj: HarvesterActivityMessage):
self._eligible_events_total += 1

def get_summary(self) -> str:
if self._eligible_events_total == 0:
return "Eligible plots 🥇: None"
return f"Eligible plots 🥇: {self._eligible_plots_total / self._eligible_events_total:0.2f} average"
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,6 @@ def consume(self, obj: HarvesterActivityMessage):
self._found_proofs_total += obj.found_proofs_count

def get_summary(self) -> str:
return f"Proofs 🧾: {self._found_proofs_total} found"
if self._found_proofs_total == 0:
return "Proofs 🧾: None"
return f"Proofs 🧾: {self._found_proofs_total} found!"
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,29 @@ class SearchTimeStats(HarvesterActivityConsumer, StatAccumulator):
def __init__(self):
self._last_reset_time = datetime.now()
self._num_measurements = 0
self._max_time_seconds = 0
self._avg_time_seconds = 0
self._over_5_seconds = 0
self._over_15_seconds = 0

def reset(self):
self._last_reset_time = datetime.now()
self._num_measurements = 0
self._max_time_seconds = 0
self._avg_time_seconds = 0
self._over_5_seconds = 0
self._over_15_seconds = 0

def consume(self, obj: HarvesterActivityMessage):
self._num_measurements += 1
self._max_time_seconds = max(self._max_time_seconds, obj.search_time_seconds)
self._avg_time_seconds += (obj.search_time_seconds - self._avg_time_seconds) / self._num_measurements
if obj.search_time_seconds > 5:
self._over_5_seconds += 1
if obj.search_time_seconds > 15:
self._over_15_seconds += 1

def get_summary(self) -> str:
return f"Search 🔍: {self._avg_time_seconds:0.2f}s average, {self._max_time_seconds:0.2f}s max"
return (
f"Search 🔍: \n"
f"\t - average: {self._avg_time_seconds:0.2f}s average\n"
f"\t - over 5s: {self._over_5_seconds} occasions\n"
f"\t - over 15s: {self._over_15_seconds} occasions"
)
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ def consume(self, obj: FinishedSignagePointMessage):
self._last_signage_point = obj.signage_point

def get_summary(self) -> str:
percentage_skipped = (self._skips_total / self._total) * 100
if self._total == 0:
return "Skipped SPs ⚠️: Unknown"
if self._skips_total > 0:
percentage_skipped = (self._skips_total / self._total) * 100
return f"Skipped SPs ⚠️: {self._skips_total} ({percentage_skipped:0.2f}%)"
return "Skipped SPs ✅️: None"
1 change: 1 addition & 0 deletions src/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,6 @@ def check_keys(required_keys, config) -> bool:
return False
return True


def is_win_platform() -> bool:
return sys.platform.startswith("win")

0 comments on commit 5ceedf8

Please sign in to comment.