Skip to content

Commit

Permalink
Tidbits with no data return None (#14)
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnScolaro authored Sep 10, 2023
1 parent ae58895 commit 74c5982
Showing 1 changed file with 40 additions and 19 deletions.
59 changes: 40 additions & 19 deletions active_statistics/statistics/trivia/summary_trivia.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ def process_activity(self, activity: Activity) -> None:
self.hottest_temp = activity.average_temp

def get_tidbit(self) -> Optional[str]:
if self.hottest_temp is None:
return None
else:
if self.hottest_temp:
return f"{self.hottest_temp} Celcius"
else:
return None

def get_description(self) -> str:
return "Highest Average Temperature"
Expand All @@ -46,10 +46,10 @@ def process_activity(self, activity: Activity) -> None:
self.coldest_temp = activity.average_temp

def get_tidbit(self) -> Optional[str]:
if self.coldest_temp is None:
return None
else:
if self.coldest_temp:
return f"{self.coldest_temp} Celcius"
else:
return None

def get_description(self) -> str:
return "Lowest Average Temperature"
Expand All @@ -69,7 +69,10 @@ def process_activity(self, activity: Activity) -> None:
self.most_people = activity.athlete_count

def get_tidbit(self) -> Optional[str]:
return f"{self.most_people} People"
if self.most_people:
return f"{self.most_people} People"
else:
return None

def get_description(self) -> str:
return "Most People on Group Activity"
Expand All @@ -95,7 +98,10 @@ def process_activity(self, activity: Activity) -> None:
self.highest_max_heartrate = activity.max_heartrate

def get_tidbit(self) -> Optional[str]:
return f"{self.highest_max_heartrate} BPM"
if self.highest_max_heartrate:
return f"{self.highest_max_heartrate} BPM"
else:
return None

def get_description(self) -> str:
return "Highest Maximum Heartrate"
Expand All @@ -121,7 +127,10 @@ def process_activity(self, activity: Activity) -> None:
self.lowest_max_heartrate = activity.max_heartrate

def get_tidbit(self) -> Optional[str]:
return f"{self.lowest_max_heartrate} BPM"
if self.lowest_max_heartrate:
return f"{self.lowest_max_heartrate} BPM"
else:
return None

def get_description(self) -> str:
return "Lowest Maximum Heartrate"
Expand All @@ -147,7 +156,10 @@ def process_activity(self, activity: Activity) -> None:
self.highest_average_heartrate = activity.average_heartrate

def get_tidbit(self) -> Optional[str]:
return f"{self.highest_average_heartrate} BPM"
if self.highest_average_heartrate:
return f"{self.highest_average_heartrate} BPM"
else:
return None

def get_description(self) -> str:
return "Highest Average Heartrate"
Expand All @@ -173,7 +185,10 @@ def process_activity(self, activity: Activity) -> None:
self.lowest_average_heartrate = activity.average_heartrate

def get_tidbit(self) -> Optional[str]:
return f"{self.lowest_average_heartrate} BPM"
if self.lowest_average_heartrate:
return f"{self.lowest_average_heartrate} BPM"
else:
return None

def get_description(self) -> str:
return "Lowest Average Heartrate"
Expand All @@ -193,7 +208,10 @@ def process_activity(self, activity: Activity) -> None:
self.max_kudos = activity.kudos_count

def get_tidbit(self) -> Optional[str]:
return f"{self.max_kudos}"
if self.max_kudos:
return f"{self.max_kudos}"
else:
return None

def get_description(self) -> str:
return "Most Kudosed Activity"
Expand All @@ -213,7 +231,10 @@ def process_activity(self, activity: Activity) -> None:
self.activity_date = activity.start_date_local

def get_tidbit(self) -> Optional[str]:
return f"{self.activity_date}"
if self.activity_date:
return f"{self.activity_date}"
else:
return None

def get_description(self) -> str:
return "First Activity"
Expand Down Expand Up @@ -253,10 +274,10 @@ def process_activity(self, activity: Activity) -> None:
self.time_of_earliest_activity = activity_time

def get_tidbit(self) -> Optional[str]:
if self.time_of_earliest_activity is None:
return None
else:
if self.time_of_earliest_activity:
return f"{self.time_of_earliest_activity}"
else:
return None

def get_description(self) -> str:
return "Earliest Activity"
Expand All @@ -281,10 +302,10 @@ def process_activity(self, activity: Activity) -> None:
self.time_of_latest_activity = activity_time

def get_tidbit(self) -> Optional[str]:
if self.time_of_latest_activity is None:
return None
else:
if self.time_of_latest_activity:
return f"{self.time_of_latest_activity}"
else:
return None

def get_description(self) -> str:
return "Latest Activity"
Expand Down

0 comments on commit 74c5982

Please sign in to comment.