From fc179ed2c833381e1ee36ddb4ea050c23d59931e Mon Sep 17 00:00:00 2001 From: Benjamyn Date: Fri, 13 Nov 2020 13:01:08 +1100 Subject: [PATCH] Abstracted getallmigrations --- migratorapi/api/views.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/migratorapi/api/views.py b/migratorapi/api/views.py index 1530727..7fb4713 100644 --- a/migratorapi/api/views.py +++ b/migratorapi/api/views.py @@ -20,13 +20,20 @@ def checkLimit(limit): else: limit = int(limit) return limit + +def getAllMigrations(limit): + return Migration.objects.all()[:limit] + +def getFilteredMigrations(limit, **kwargs): + pass + class MigrationList(APIView): ''' Returns a list of migrations with simpleData ''' def get(self, request, format=None): limit = checkLimit(request.GET.get('limit', '')) - migrations = Migration.objects.all()[:limit] + migrations = getAllMigrations(limit) serializer = MigrationOverView(migrations, many=True) return Response(serializer.data) @@ -132,6 +139,6 @@ class PendingTerm(APIView): class MigrationListAll(APIView): def get(self, request, format=None): limit = checkLimit(request.GET.get('limit', '')) - migrations = Migration.objects.all()[:limit] + migrations = getAllMigrations(limit) serializer = MigrationSerializer(migrations, many=True) return Response(serializer.data)