Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: percentage zero error. #1847

Merged
merged 1 commit into from
Sep 22, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading