Compare commits

..

No commits in common. "ff5d3a10e5082dab389b85ceaa9c828a23951cfb" and "f63af5c3a9436a406ff5e50913d02500996c36ae" have entirely different histories.

View File

@ -308,39 +308,26 @@ class AppointmentStatsView(generics.GenericAPIView):
availability = get_admin_availability()
availability_coverage = 0
available_days_count = 0
if availability and availability.availability_schedule:
available_days_count = len(availability.availability_schedule)
availability_coverage = round((available_days_count / 7) * 100, 2)
def pct(count):
return round((count / total * 100), 2) if total > 0 else 0
days_with_availability = len(availability.availability_schedule)
availability_coverage = round((days_with_availability / 7) * 100, 2)
return Response({
'total_requests': total,
'users': users,
'users_pct': pct(users),
'pending_review': pending,
'pending_review_pct': pct(pending),
'scheduled': scheduled,
'scheduled_pct': pct(scheduled),
'rejected': rejected,
'rejected_pct': pct(rejected),
'completed': completed,
'completed_pct': pct(completed),
'users': users,
'completion_rate': round((scheduled / total * 100), 2) if total > 0 else 0,
'availability_coverage': availability_coverage,
'available_days_count': days_with_availability if availability else 0,
'jitsi_meetings_created': jitsi_meetings,
'meetings_with_video_pct': pct(jitsi_meetings),
'active_upcoming_meetings': active_meetings,
'available_days_count': available_days_count,
'availability_coverage_pct': availability_coverage,
'meetings_with_video': round((jitsi_meetings / total * 100), 2) if total > 0 else 0,
})
class UserAppointmentStatsView(generics.GenericAPIView):
permission_classes = [IsAuthenticated]
serializer_class = AppointmentDetailSerializer
@ -372,25 +359,23 @@ class UserAppointmentStatsView(generics.GenericAPIView):
}
total = stats['total']
pending = stats['pending']
completed = stats['completed']
scheduled = stats['scheduled']
pending_pct = round((pending / total * 100), 2) if total > 0 else 0
completed_pct = round((completed / total * 100), 2) if total > 0 else 0
scheduled_pct = round((scheduled / total * 100), 2) if total > 0 else 0
completion_rate = round((scheduled / total * 100), 2) if total > 0 else 0
return Response({
'total_requests': total,
'pending_review': pending,
'pending_review_pct': pending_pct,
'pending_review': stats['pending'],
'scheduled': scheduled,
'scheduled_pct': scheduled_pct,
'rejected': stats['rejected'],
'completed': completed,
'completed_pct': completed_pct,
'completion_rate': round((scheduled / total * 100), 2) if total > 0 else 0,
'completed': stats['completed'],
'video_meetings': stats['video_meetings'],
'completion_rate': completion_rate,
'email': request.user.email,
'upcoming_video_sessions': queryset.filter(
status='scheduled',
jitsi_meeting_created=True,
scheduled_datetime__gt=timezone.now()
).count(),
})
class MatchingAvailabilityView(generics.GenericAPIView):