Skip to content

Commit

Permalink
better handling zero-data conditions in graph
Browse files Browse the repository at this point in the history
  • Loading branch information
digitalfox committed Nov 19, 2024
1 parent e88bda0 commit 256039c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion billing/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -742,7 +742,7 @@ def graph_yearly_billing(request):
growth.append(None)
last_turnover = current_turnover

if years[-1] == date.today().year:
if years and years[-1] == date.today().year:
growth.pop() # Don't compute for on-going year.

graph_data.append(["x"] + years) # X (years) axis
Expand Down
3 changes: 3 additions & 0 deletions leads/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -511,6 +511,9 @@ def graph_leads_activity(request):
if subsidiary:
leads = leads.filter(subsidiary=subsidiary)

if not leads:
return HttpResponse('')

# lead creation rate per week
first_lead_creation_date = leads.aggregate(Min("creation_date")).get("creation_date__min", datetime.now()).date()
today = date.today()
Expand Down

0 comments on commit 256039c

Please sign in to comment.