Use only when retrieving the config attr
Just a little optimization
@@ -174,10 +174,13 @@ class Version(models.Model):
:rtype: dict
"""
last_build = (
- self.builds.filter(
+ self.builds
+ .filter(
state='finished',
success=True,
- ).order_by('-date').first()
+ ).order_by('-date')
+ .only('_config')
+ .first()
)
return last_build.config
@@ -636,7 +639,12 @@ class Build(models.Model):
ones).
"""
if self.CONFIG_KEY in self._config:
- return Build.objects.get(pk=self._config[self.CONFIG_KEY])._config
+ return (
+ Build.objects
+ .only('_config')
+ .get(pk=self._config[self.CONFIG_KEY])
+ ._config
+ )
return self._config
@config.setter
