Skip to content

Commit

Permalink
Remove canonical_preview_image from entry schema
Browse files Browse the repository at this point in the history
  • Loading branch information
sudan45 committed Jun 20, 2024
1 parent 56c2530 commit 296fe3f
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 32 deletions.
25 changes: 0 additions & 25 deletions apps/entry/dataloaders.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,27 +120,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):
Expand Down Expand Up @@ -173,7 +152,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)
6 changes: 0 additions & 6 deletions apps/entry/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down
1 change: 0 additions & 1 deletion schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -4101,7 +4101,6 @@ type EntryType {
reviewCommentsCount: Int!
draftEntry: ID
entryAttachment: EntryAttachmentType
canonicalPreviewImage: String
}

scalar EnumDescription
Expand Down

0 comments on commit 296fe3f

Please sign in to comment.