Skip to content

Commit

Permalink
Fix : null value for stats
Browse files Browse the repository at this point in the history
  • Loading branch information
kshitijrajsharma committed Jan 30, 2024
1 parent bc89ba9 commit 62e57a4
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -1011,7 +1011,12 @@ def get_building_pattern_statement(
Returns:
str: Human-readable building statement.
"""
building_statement = f"OpenStreetMap contains roughly {humanize.intword(osm_building_count)} buildings in this region. Based on AI-mapped estimates, this is approximately {round((osm_building_count/ai_building_count)*100)}% of the total buildings. The average age of data for this region is {humanize.naturaltime(avg_timestamp).replace('ago', '')}( Last edited {humanize.naturaltime(last_edit_timestamp)} ) and {round((osm_building_count_6_months/ai_building_count)*100)}% buildings were added or updated in the last 6 months."
building_statement = f"OpenStreetMap contains roughly {humanize.intword(osm_building_count)} buildings in this region. "
if ai_building_count > 0:
building_statement += f"Based on AI-mapped estimates, this is approximately {round((osm_building_count/ai_building_count)*100)}% of the total buildings."
building_statement += f"The average age of data for this region is {humanize.naturaltime(avg_timestamp).replace('ago', '')}( Last edited {humanize.naturaltime(last_edit_timestamp)} ) "
if osm_building_count > 0:
building_statement += f"and {round((osm_building_count_6_months/osm_building_count)*100)}% buildings were added or updated in the last 6 months."
return building_statement

@staticmethod
Expand All @@ -1034,7 +1039,12 @@ def get_road_pattern_statement(
Returns:
str: Human-readable road statement.
"""
road_statement = f"OpenStreetMap contains roughly {humanize.intword(osm_highway_length)} km of roads in this region. Based on AI-mapped estimates, this is approximately {round(osm_highway_length/ai_highway_length*100)} % of the total road length in the dataset region. The average age of data for the region is {humanize.naturaltime(avg_timestamp).replace('ago', '')} ( Last edited {humanize.naturaltime(last_edit_timestamp)} ) and {round((osm_highway_length_6_months/osm_highway_length)*100)}% of roads were added or updated in the last 6 months."
road_statement = f"OpenStreetMap contains roughly {humanize.intword(osm_highway_length)} km of roads in this region. "
if ai_highway_length > 1:
road_statement += f"Based on AI-mapped estimates, this is approximately {round(osm_highway_length/ai_highway_length*100)} % of the total road length in the dataset region. "
road_statement += f"The average age of data for the region is {humanize.naturaltime(avg_timestamp).replace('ago', '')} ( Last edited {humanize.naturaltime(last_edit_timestamp)} ) "
if osm_highway_length > 1:
road_statement += f"and {round((osm_highway_length_6_months/osm_highway_length)*100)}% of roads were added or updated in the last 6 months."
return road_statement

def get_osm_analytics_meta_stats(self):
Expand Down

0 comments on commit 62e57a4

Please sign in to comment.