Skip to content

Commit

Permalink
get rid of none
Browse files Browse the repository at this point in the history
  • Loading branch information
asennoussi committed Sep 17, 2022
1 parent a14b147 commit 6e7aef7
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions dashboard/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
from django.views.decorators.csrf import csrf_exempt
from django.views.generic import (ListView, RedirectView, TemplateView,
UpdateView)
from django.db.models.functions import Coalesce
from emailguru.utils import (LinkedAccounts, create_or_update_linked_account,
get_associated_email, get_google_flow,
get_paypal_button, get_scopes, handle_email,
Expand Down Expand Up @@ -83,7 +84,7 @@ def get_context_data(self, **kwargs):
owner=self.request.user, process_status='filtered').aggregate(Sum('count_emails'))['count_emails__sum']
context['total_filtered_today'] = FilteredEmails.objects.filter(
owner=self.request.user, process_status='filtered', date_filtered=datetime.now()).aggregate(
Sum('count_emails'))['count_emails__sum']
Sum('count_emails'))['count_emails__sum'] or 0
context['time_saved'] = int(context['total_filtered'] or 0) / \
360 # Total hours saved
context['filteration_rate'] = int(context['total_filtered'] or 0) / \
Expand Down Expand Up @@ -211,7 +212,7 @@ class LinkedaccountsView(LoginRequiredMixin, ListView):
def get_queryset(self):
total_filtered = Sum('filteredemails__count_emails', filter=Q(
filteredemails__process_status='filtered'))
total_processed = Sum('filteredemails__count_emails')
total_processed = Coalesce(Sum('filteredemails__count_emails'), 0)
return (
LinkedAccounts.objects.filter(
owner=self.request.user, deleted=False)
Expand Down

0 comments on commit 6e7aef7

Please sign in to comment.