Skip to content

Commit

Permalink
OpenConceptLab/ocl_issues#857 | Source/collection child max updated a…
Browse files Browse the repository at this point in the history
…t to select only updated_at field
  • Loading branch information
snyaggarwal committed Jul 29, 2021
1 parent c31da3e commit bd07d32
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 4 deletions.
4 changes: 2 additions & 2 deletions core/common/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -364,14 +364,14 @@ def active_mappings(self):
def last_concept_update(self):
updated_at = None
if self.concepts.exists():
updated_at = self.concepts.latest('updated_at').updated_at
updated_at = self.concepts.only('updated_at').latest('updated_at').updated_at
return updated_at

@property
def last_mapping_update(self):
updated_at = None
if self.mappings.exists():
updated_at = self.mappings.latest('updated_at').updated_at
updated_at = self.mappings.only('updated_at').latest('updated_at').updated_at
return updated_at

@property
Expand Down
3 changes: 2 additions & 1 deletion core/concepts/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,8 @@ class Meta:
'owner', 'owner_type', 'owner_url', 'display_name', 'display_locale', 'names', 'descriptions',
'created_on', 'updated_on', 'versions_url', 'version', 'extras', 'parent_id', 'name', 'type',
'update_comment', 'version_url', 'mappings', 'updated_by', 'created_by', 'internal_reference_id',
'parent_concept_urls', 'child_concept_urls', 'parent_concepts', 'child_concepts', 'hierarchy_path'
'parent_concept_urls', 'child_concept_urls', 'parent_concepts', 'child_concepts', 'hierarchy_path',
'public_can_view',
)

def get_mappings(self, obj):
Expand Down
4 changes: 3 additions & 1 deletion core/integration_tests/tests_concepts.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ def test_post_201(self):
'created_by',
'internal_reference_id',
'hierarchy_path',
'public_can_view',
]
)

Expand Down Expand Up @@ -197,7 +198,8 @@ def test_put_200(self):
'updated_by',
'created_by',
'internal_reference_id',
'hierarchy_path']
'hierarchy_path',
'public_can_view']
)

version = Concept.objects.last()
Expand Down
1 change: 1 addition & 0 deletions core/mappings/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ class Meta:
fields = MappingListSerializer.Meta.fields + (
'type', 'uuid', 'extras', 'created_on', 'updated_on',
'created_by', 'updated_by', 'parent_id', 'internal_reference_id',
'public_can_view',
)

def create(self, validated_data):
Expand Down

0 comments on commit bd07d32

Please sign in to comment.