Skip to content

Commit

Permalink
using latest rather than aggregate for source/collection updated_at
Browse files Browse the repository at this point in the history
  • Loading branch information
snyaggarwal committed Jan 17, 2021
1 parent 76f3410 commit cc3c3d2
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions core/common/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from django.core.exceptions import ValidationError
from django.core.validators import RegexValidator
from django.db import models, IntegrityError
from django.db.models import Max, Value, Q
from django.db.models import Value, Q
from django.db.models.expressions import CombinedExpression, F
from django.utils import timezone
from django_elasticsearch_dsl.registries import registry
Expand Down Expand Up @@ -569,15 +569,13 @@ def __get_last_concept_updated_at(self):
concepts = self.concepts
if not concepts.exists():
return None
agg = concepts.aggregate(Max('updated_at'))
return agg.get('updated_at__max')
return concepts.latest('updated_at').updated_at

def __get_last_mapping_updated_at(self):
mappings = self.mappings
if not mappings.exists():
return None
agg = mappings.aggregate(Max('updated_at'))
return agg.get('updated_at__max')
return mappings.latest('updated_at').updated_at

def __get_last_child_updated_at(self):
last_concept_update = self.last_concept_update
Expand Down

0 comments on commit cc3c3d2

Please sign in to comment.