Skip to content

Commit

Permalink
Add support for pagination for 3D mappings (#11)
Browse files Browse the repository at this point in the history
  • Loading branch information
KirtiGautam authored Mar 16, 2021
1 parent 685ee9c commit 31f933f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
10 changes: 9 additions & 1 deletion fyle_accounting_mappings/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from rest_framework.generics import ListCreateAPIView
from rest_framework.response import Response
from rest_framework.views import status
from django.db.models import Count

from .exceptions import BulkError
from .utils import assert_valid
Expand Down Expand Up @@ -53,7 +54,14 @@ def get_queryset(self):

assert_valid(source_type is not None, 'query param source type not found')

return Mapping.objects.filter(source_type=source_type, workspace_id=self.kwargs['workspace_id'])
if int(self.request.query_params.get('table_dimension')) == 3:
mappings = Mapping.objects.filter(source_id__in=Mapping.objects.filter(
source_type=source_type, workspace_id=self.kwargs['workspace_id']).values('source_id').annotate(
count=Count('source_id')).filter(count=2).values_list('source_id'))
else:
mappings = Mapping.objects.filter(source_type=source_type, workspace_id=self.kwargs['workspace_id'])

return mappings.order_by('source__value')

def post(self, request, *args, **kwargs):
"""
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

setuptools.setup(
name='fyle-accounting-mappings',
version='0.11.0',
version='0.12.0',
author='Shwetabh Kumar',
author_email='[email protected]',
description='Django application to store the fyle accounting mappings in a generic manner',
Expand Down

0 comments on commit 31f933f

Please sign in to comment.