first commit
This commit is contained in:
23
Base/Metrics/DashboardProf/get_total_serv.py
Normal file
23
Base/Metrics/DashboardProf/get_total_serv.py
Normal file
@@ -0,0 +1,23 @@
|
||||
from django.db.models import Sum , Count
|
||||
from django.utils import timezone
|
||||
from Movement.models import (
|
||||
Calendar,
|
||||
)
|
||||
|
||||
def metric(Prof_id):
|
||||
current_month = timezone.localtime(timezone.now()).month
|
||||
current_year = timezone.localtime(timezone.now()).year
|
||||
|
||||
qs = Calendar.objects.filter(
|
||||
professional_id=Prof_id,
|
||||
date__month=current_month,
|
||||
date__year=current_year,
|
||||
)
|
||||
# Contagem de cada serviço realizado
|
||||
services_breakdown = qs.values('service__name').annotate(
|
||||
total_performed=Count('id')
|
||||
).order_by('-total_performed')
|
||||
|
||||
return {
|
||||
'services': services_breakdown,
|
||||
}
|
||||
Reference in New Issue
Block a user