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 # May raise a permission denied
self.check_object_permissions(self.request, collection) 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 # Guide

View File

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

View File

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