Skip to content

Commit

Permalink
Merge pull request #1847 from Bidaya0/feat/project_type_summary-p2
Browse files Browse the repository at this point in the history
fix: percentage zero error.
  • Loading branch information
Bidaya0 authored Sep 22, 2023
2 parents 194a324 + 06b38a9 commit aff7aad
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions dongtai_web/views/utils/commonstats.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,9 @@ def get_summary_by_project(project_id: int, project_version_id: int):
)
type_summary_total_count = sum(i["type_count"] for i in data["type_summary"])
for type_summary in data["type_summary"]:
if type_summary_total_count == 0:
type_summary["level_total_percentage"] = 0
continue
type_summary["type_total_percentage"] = type_summary["type_total_percentage"] / type_summary_total_count
current_timestamp, a_week_ago_timestamp, days = weeks_ago(week=1)
daylist = []
Expand Down Expand Up @@ -244,6 +247,9 @@ def get_summary_by_project(project_id: int, project_version_id: int):
data["level_count"] = levelNum
level_total_count = sum(i["num"] for i in data["level_count"])
for level in data["level_count"]:
if level_total_count == 0:
level["level_total_percentage"] = 0
continue
level["level_total_percentage"] = level["num"] / level_total_count
return data

Expand Down

0 comments on commit aff7aad

Please sign in to comment.