diff --git a/backend/api/management/commands/seed_db.py b/backend/api/management/commands/seed_db.py index 76ea0a98..11a07a33 100644 --- a/backend/api/management/commands/seed_db.py +++ b/backend/api/management/commands/seed_db.py @@ -491,26 +491,26 @@ def seed_data(self, amount, provider_function, update_function): def handle(self, *args, **options): start_time = time.time() # TODO maybey take as option - # amount_of_students = 50_000 - # amount_of_assistants = 300 - # amount_of_teachers = 500 - # amount_of_courses = 1_000 - # amount_of_projects = 3_000 - # amount_of_groups = 9_000 - # amount_of_submissions = 50_000 - # amount_of_file_extensions = 20 - # amount_of_structure_checks = 12_000 - - amount_of_students = 10 - amount_of_assistants = 0 - amount_of_teachers = 0 - amount_of_courses = 0 - amount_of_projects = 0 - amount_of_groups = 0 - amount_of_submissions = 0 + amount_of_students = 50_000 + amount_of_assistants = 5_000 + amount_of_teachers = 1_500 + amount_of_courses = 1_500 + amount_of_projects = 3_000 + amount_of_groups = 3_000 + amount_of_submissions = 3_000 amount_of_file_extensions = 0 amount_of_structure_checks = 0 + # amount_of_students = 10 + # amount_of_assistants = 0 + # amount_of_teachers = 0 + # amount_of_courses = 0 + # amount_of_projects = 0 + # amount_of_groups = 0 + # amount_of_submissions = 0 + # amount_of_file_extensions = 0 + # amount_of_structure_checks = 0 + self.seed_data(amount_of_students, fake.provide_student, update_Student_providers) self.stdout.write(self.style.SUCCESS('Successfully seeded students!')) self.seed_data(amount_of_assistants, fake.provide_assistant, update_Assistant_providers) diff --git a/backend/api/views/course_view.py b/backend/api/views/course_view.py index 087b9703..3b17ea1d 100644 --- a/backend/api/views/course_view.py +++ b/backend/api/views/course_view.py @@ -1,3 +1,5 @@ +from django.db.models import Min, Max + from api.models.course import Course from api.permissions.course_permissions import (CourseAssistantPermission, CoursePermission, @@ -26,6 +28,8 @@ from rest_framework.request import Request from rest_framework.response import Response +from api.views.pagination.course_pagination import CoursePagination + class CourseViewSet(viewsets.ModelViewSet): """Actions for general course logic""" @@ -47,10 +51,8 @@ def create(self, request: Request, *_): return Response(serializer.data, status=status.HTTP_201_CREATED) - @action(detail=False) + @action(detail=False, pagination_class=CoursePagination) def search(self, request: Request) -> Response: - self.pagination_class = BasicPagination - # Extract filter params search = request.query_params.get("search", "") years = request.query_params.getlist("years[]") diff --git a/backend/api/views/pagination/course_pagination.py b/backend/api/views/pagination/course_pagination.py new file mode 100644 index 00000000..449389fc --- /dev/null +++ b/backend/api/views/pagination/course_pagination.py @@ -0,0 +1,21 @@ +from django.db.models import Min, Max +from rest_framework.response import Response +from api.models.course import Course +from api.views.pagination.basic_pagination import BasicPagination + + +class CoursePagination(BasicPagination): + def get_paginated_response(self, schema): + # Get min and max years + years = Course.objects.all().aggregate( + Min('academic_startyear'), Max('academic_startyear') + ) + + return Response({ + 'count': self.page.paginator.count, + 'next': self.get_next_link(), + 'previous': self.get_previous_link(), + 'min_year': years['academic_startyear__min'], + 'max_year': years['academic_startyear__max'], + 'results': schema, + }) diff --git a/frontend/src/components/projects/ProjectList.vue b/frontend/src/components/projects/ProjectList.vue index fc0c9aa2..4fdf4a24 100644 --- a/frontend/src/components/projects/ProjectList.vue +++ b/frontend/src/components/projects/ProjectList.vue @@ -1,22 +1,21 @@