Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix media expiry from mongo #2336

Merged
merged 1 commit into from
Apr 13, 2022
Merged

Conversation

petrjasek
Copy link
Member

removing of expired media items didn't work
as we were not using ObjectId but str.

also remove media_references when deleting
an item so those won't prevent published
media from being removed.

SDESK-6432

removing of expired media items didn't work
as we were not using ObjectId but str.

also remove media_references when deleting
an item so those won't prevent published
media from being removed.

SDESK-6432
@petrjasek petrjasek added this to the 2.4.1 milestone Apr 12, 2022

for attachment in doc.get("attachments", []):
lookup = {"_id": attachment["attachment"]}
get_resource_service("attachments").delete_action(lookup)


def remove_media_references(item_id, published):
get_resource_service("media_references").delete_action({"item_id": item_id, "published": published})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would this need an index for published, or do you think this should be fast enough?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there is item_id index and then it's only a few items to be checked so should be fine

@petrjasek petrjasek merged commit f27a11e into superdesk:develop Apr 13, 2022
@petrjasek petrjasek deleted the fix-media-expiry branch April 13, 2022 06:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants