try to fix performance issues

(cherry picked from commit 964ead1)
This commit is contained in:
Kuroshini 2020-01-16 12:13:43 +03:00
parent 0b261330e6
commit 127d15b181
3 changed files with 7 additions and 3 deletions

View File

@ -65,7 +65,8 @@ class CollectionEstablishmentListView(CollectionListView):
# May raise a permission denied
self.check_object_permissions(self.request, collection)
return collection.establishments.published().annotate_in_favorites(self.request.user)
return collection.establishments.published().annotate_in_favorites(self.request.user) \
.with_base_related().with_extended_related()
# Guide

View File

@ -775,8 +775,9 @@ class Establishment(GalleryMixin, ProjectBaseMixin, URLImageMixin,
@property
def main_image(self):
qs = self.establishment_gallery.main_image()
if qs.exists():
return qs.first().image
image_model = qs.first()
if image_model is not None:
return image_model.image
@property
def restaurant_category_indexing(self):

View File

@ -536,3 +536,5 @@ COOKIE_DOMAIN = None
ELASTICSEARCH_DSL = {}
ELASTICSEARCH_INDEX_NAMES = {}
THUMBNAIL_FORCE_OVERWRITE = True