From e3d6f09adaf1790f9b3607106371ff075264eece Mon Sep 17 00:00:00 2001 From: sudan45 Date: Thu, 20 Jun 2024 11:39:40 +0545 Subject: [PATCH] Remove canonical_preview_image from entry schema --- apps/entry/dataloaders.py | 26 -------------------------- apps/entry/schema.py | 6 ------ schema.graphql | 1 - 3 files changed, 33 deletions(-) diff --git a/apps/entry/dataloaders.py b/apps/entry/dataloaders.py index 1dd0df1816..d24f3e6317 100644 --- a/apps/entry/dataloaders.py +++ b/apps/entry/dataloaders.py @@ -1,5 +1,4 @@ from collections import defaultdict -from deep.serializers import URLCachedFileField from promise import Promise from django.utils.functional import cached_property from django.db import models @@ -120,27 +119,6 @@ def batch_load_fn(self, keys): return Promise.resolve([counts.get(key, 0) for key in keys]) -class EntryImageUrlLoader(DataLoaderWithContext): - def batch_load_fn(self, keys): - entry_qs = Entry.objects.filter(id__in=keys) - entry_dict = {entry.id: entry for entry in entry_qs} - results = [] - for key in keys: - entry = entry_dict.get(key) - if entry.entry_type == Entry.TagType.IMAGE: - url = self.context.request.build_absolute_uri( - URLCachedFileField.name_to_representation(entry.image) - ) - elif entry.entry_type == Entry.TagType.ATTACHMENT: - url = self.context.request.build_absolute_uri( - URLCachedFileField.name_to_representation(entry.entry_attachment.file) - ) - else: - url = None - results.append(url) - return Promise.resolve(results) - - class DataLoaders(WithContextMixin): @cached_property def entry(self): @@ -173,7 +151,3 @@ def verified_by(self): @cached_property def verified_by_count(self): return EntryVerifiedByCountLoader(context=self.context) - - @cached_property - def entry_image_preview_url(self): - return EntryImageUrlLoader(context=self.context) diff --git a/apps/entry/schema.py b/apps/entry/schema.py index 34f43282ca..b11e995194 100644 --- a/apps/entry/schema.py +++ b/apps/entry/schema.py @@ -118,7 +118,6 @@ class Meta: review_comments_count = graphene.Int(required=True) draft_entry = graphene.ID(source="draft_entry_id") entry_attachment = graphene.Field(EntryAttachmentType, required=False) - canonical_preview_image = graphene.String(required=False) # project_labels TODO: # tabular_field TODO: @@ -153,11 +152,6 @@ def resolve_verified_by_count(root, info, **_): return len(root.verified_by.all()) return info.context.dl.entry.verified_by_count.load(root.pk) - @staticmethod - # NOTE: Client might not need this field so we have not refactor the dataloader - def resolve_canonical_preview_image(root, info, **_): - return info.context.dl.entry.entry_image_preview_url.load(root.pk) - class EntryListType(CustomDjangoListObjectType): class Meta: diff --git a/schema.graphql b/schema.graphql index 0cbf925e9d..d01ad62fc4 100644 --- a/schema.graphql +++ b/schema.graphql @@ -4101,7 +4101,6 @@ type EntryType { reviewCommentsCount: Int! draftEntry: ID entryAttachment: EntryAttachmentType - canonicalPreviewImage: String } scalar EnumDescription