File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 55from django .core .exceptions import ValidationError
66from django .core .validators import RegexValidator
77from django .db import models , IntegrityError
8- from django .db .models import Value , Q
8+ from django .db .models import Value , Q , Max
99from django .db .models .expressions import CombinedExpression , F
1010from django .utils import timezone
1111from django .utils .functional import cached_property
@@ -362,20 +362,11 @@ def active_mappings(self):
362362
363363 @property
364364 def last_concept_update (self ):
365- # Use 'values_list' instead of 'first' so as not load any concepts...
366- updated_at = self .concepts .order_by ('-updated_at' ).values_list ('updated_at' , flat = True )[:1 ]
367- if updated_at :
368- return updated_at [0 ]
369- return None
365+ return get (self .concepts .aggregate (max_updated_at = Max ('updated_at' )), 'max_updated_at' , None )
370366
371367 @property
372368 def last_mapping_update (self ):
373- # Use 'values_list' instead of 'first' so as not load any mappings...
374- updated_at = self .mappings .order_by ('-updated_at' ).values_list ('updated_at' , flat = True )[:1 ]
375- if updated_at :
376- return updated_at [0 ]
377-
378- return None
369+ return get (self .mappings .aggregate (max_updated_at = Max ('updated_at' )), 'max_updated_at' , None )
379370
380371 @property
381372 def last_child_update (self ):
You can’t perform that action at this time.
0 commit comments