Skip to content

Commit

Permalink
Handle stats mapping api for config updates (#53)
Browse files Browse the repository at this point in the history
Handle stats mapping api for config updates (#53)
  • Loading branch information
Sravanksk authored Apr 21, 2022
1 parent 9b77c53 commit 0475667
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
13 changes: 11 additions & 2 deletions fyle_accounting_mappings/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,20 +173,29 @@ class MappingStatsView(ListCreateAPIView):
"""
def get(self, request, *args, **kwargs):
source_type = self.request.query_params.get('source_type')
destination_type = self.request.query_params.get('destination_type')

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

total_attributes_count = ExpenseAttribute.objects.filter(
attribute_type=source_type, workspace_id=self.kwargs['workspace_id']
).count()

if source_type == 'EMPLOYEE':
filters = {}

if destination_type == 'VENDOR':
filters['destination_vendor__attribute_type'] = destination_type
else:
filters['destination_employee__attribute_type'] = destination_type

mapped_attributes_count = EmployeeMapping.objects.filter(
workspace_id=self.kwargs['workspace_id']
**filters, workspace_id=self.kwargs['workspace_id']
).count()
else:
mapped_attributes_count = Mapping.objects.filter(
source_type=source_type, workspace_id=self.kwargs['workspace_id']
source_type=source_type, destination_type=destination_type, workspace_id=self.kwargs['workspace_id']
).count()

return Response(
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='1.14.0',
version='1.15.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 0475667

Please sign in to comment.