Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
rkorytkowski committed Jan 26, 2023
1 parent 4c5ee31 commit 3e777b7
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions core/concept_maps/serializers.py
Expand Up @@ -45,10 +45,7 @@ def to_internal_value(self, data):
def to_representation(self, value):
# limit to 1000 mappings by default
# TODO: support graphQL to go around the limit
if self.context.get('has_many', False):
limit = 25
else:
limit = 1000
limit = self.get_limit()
mappings = value.get_mappings_queryset().order_by('id')[:limit]
groups = {}
for mapping in mappings:
Expand Down Expand Up @@ -95,6 +92,13 @@ def to_representation(self, value):
})
return [*groups.values()]

def get_limit(self):
if self.context.get('has_many', False):
limit = 25
else:
limit = 1000
return limit


class ConceptMapDetailSerializer(serializers.ModelSerializer):
resourceType = SerializerMethodField(method_name='get_resource_type')
Expand Down

0 comments on commit 3e777b7

Please sign in to comment.