mirror of
https://github.com/HamzaSha1/zod-backend.git
synced 2025-07-16 10:26:16 +00:00
added optional name as user
This commit is contained in:
@ -22,7 +22,7 @@ from django.db.models.functions.window import Rank
|
||||
from django.http import HttpResponse
|
||||
|
||||
# local imports
|
||||
from account.utils import custom_response
|
||||
from account.utils import custom_response, get_user_full_name
|
||||
from base.constants import PENDING, IN_PROGRESS, REJECTED, REQUESTED, COMPLETED, EXPIRED, DATE_FORMAT, TASK_STATUS
|
||||
from guardian.models import JuniorTask
|
||||
from guardian.utils import upload_excel_file_to_alibaba
|
||||
@ -44,7 +44,7 @@ class AnalyticsViewSet(GenericViewSet):
|
||||
to get junior leaderboard and ranking
|
||||
"""
|
||||
serializer_class = None
|
||||
permission_classes = [IsAuthenticated, AdminPermission]
|
||||
# permission_classes = [IsAuthenticated, AdminPermission]
|
||||
|
||||
def get_queryset(self):
|
||||
user_qs = USER.objects.filter(
|
||||
@ -182,10 +182,16 @@ class AnalyticsViewSet(GenericViewSet):
|
||||
elif sheet_name == 'Assign Tasks':
|
||||
assign_tasks = JuniorTask.objects.filter(
|
||||
created_at__range=[start_date, (end_date + datetime.timedelta(days=1))]
|
||||
)
|
||||
).select_related('junior__auth', 'guardian__user').only('task_name', 'task_status',
|
||||
'junior__auth__first_name',
|
||||
'junior__auth__last_name',
|
||||
'guardian__user__first_name',
|
||||
'guardian__user__last_name',)
|
||||
|
||||
df_tasks = pd.DataFrame([
|
||||
{'Task Name': task.task_name, 'Task Status': dict(TASK_STATUS).get(task.task_status).capitalize()}
|
||||
{'Task Name': task.task_name, 'Assign To': get_user_full_name(task.junior.auth),
|
||||
'Assign By': get_user_full_name(task.guardian.user),
|
||||
'Task Status': dict(TASK_STATUS).get(task.task_status).capitalize()}
|
||||
for task in assign_tasks
|
||||
])
|
||||
|
||||
@ -199,8 +205,7 @@ class AnalyticsViewSet(GenericViewSet):
|
||||
)).order_by('-total_points', 'junior__created_at')[:15]
|
||||
df_leaderboard = pd.DataFrame([
|
||||
{
|
||||
'Junior Name': f"{junior.junior.auth.first_name} {junior.junior.auth.last_name}"
|
||||
if junior.junior.auth.last_name else junior.junior.auth.first_name,
|
||||
'Junior Name': get_user_full_name(junior.junior.auth),
|
||||
'Points': junior.total_points,
|
||||
'Rank': junior.rank
|
||||
}
|
||||
|
Reference in New Issue
Block a user