Skip to content

Commit

Permalink
fix: performance
Browse files Browse the repository at this point in the history
  • Loading branch information
francesco-filicetti committed Oct 12, 2023
1 parent 6a0c4b3 commit da0a3b5
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
6 changes: 4 additions & 2 deletions uniticket/uni_ticket/views/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,15 @@ def dashboard(request, structure_slug, structure):
my_opened = assignments.filter(ticket__assigned_date__isnull=False, ticket__is_closed=False, taken_by=request.user).values('ticket__code').annotate(total=Count('ticket__code')).count()
om = OrganizationalStructureOffice
offices = om.objects.filter(organizational_structure=structure)\
.annotate(Count('ticketassignment'))\
.annotate(Count('organizationalstructureofficeemployee'))\
.prefetch_related('ticketcategory_set')

cm = TicketCategory
categories = cm.objects.filter(organizational_structure=structure)\
.select_related('organizational_office')\
.prefetch_related('ticketcategorycondition_set')\
.prefetch_related('ticketcategorytask_set')
.annotate(Count('ticketcategorycondition'))\
.annotate(Count('ticketcategorytask'))
# disabled_expired_items(categories)

# messages = TicketReply.get_unread_messages_count(tickets=tickets)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,10 @@ <h5 class="card-title">{{ category.name }}</h5>
{{ category.date_end | default:"-" }}
<br>
<b>{% trans 'Clausole attive' %}:</b>
{{ category.ticketcategorycondition_set.all.count }}
{{ category.ticketcategorycondition__count }}
<br>
<b>{% trans 'Attività predefinite attive' %}:</b>
{{ category.ticketcategorytask_set.all.count }}
{{ category.ticketcategorytask__count }}
<br>
<b>{% trans 'Notifica email a operatori' %}:</b>
<svg class="icon icon-xs">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ <h5 class="card-title">{{ office.name }}</h5>
<p class="card-text">{{ office.description }}</p>
<p class="card-text">
<b>{% trans 'Operatori' %}:</b>
{{ office.organizationalstructureofficeemployee_set.all.count }}
{{ office.organizationalstructureofficeemployee__count }}
<br>
<b>{% trans 'Ad uso interno' %}:</b>
<svg class="icon icon-sm icon-secondary">
Expand All @@ -60,7 +60,7 @@ <h5 class="card-title">{{ office.name }}</h5>
</svg>
<br>
<b>{% trans 'Richieste assegnate' %}:</b>
{{ office.ticketassignment_set.all.count }}
{{ office.ticketassignment__count }}
<br>
<b>{% trans 'Categorie di competenza' %}:</b>
{% if office.ticketcategory_set.all %}
Expand Down

0 comments on commit da0a3b5

Please sign in to comment.