From 7d407c1a6a3be9eeb4dd45fe32e4833fb6c1b996 Mon Sep 17 00:00:00 2001 From: frimpongopoku Date: Thu, 9 Nov 2023 13:30:30 +0000 Subject: [PATCH 1/2] get summary without feature flag --- src/task_queue/database_tasks/media_library_cleanup.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/task_queue/database_tasks/media_library_cleanup.py b/src/task_queue/database_tasks/media_library_cleanup.py index db99fa3bf..e635798da 100644 --- a/src/task_queue/database_tasks/media_library_cleanup.py +++ b/src/task_queue/database_tasks/media_library_cleanup.py @@ -11,14 +11,14 @@ ) from api.store.media_library import MediaLibraryStore as media_store from api.utils.constants import MEDIA_LIBRARY_CLEANUP_TEMPLATE -from database.models import FeatureFlag +from database.models import Community, FeatureFlag from task_queue.models import Task REMOVE_DUPLICATE_IMAGE_FLAG_KEY = "remove-duplicate-images-feature-flag" -def remove_duplicate_images(task): +def remove_duplicate_images(task=None): """ This checks all media on the platform and removes all duplicates. Its based on the "Remove Duplicate Images" feature flag. For communities that are subscribed @@ -33,9 +33,13 @@ def remove_duplicate_images(task): print("Generating hashes") result = media_store.generate_hashes(None, None, None) - communities = flag.enabled_communities() + if flag: + communities = flag.enabled_communities() + else: + communities = Community.objects.all() # task = Task.objects.filter(name="Media Library Cleanup Routine").first() ids = [c.id for c in communities] + print("Here are the ids", ids) clean_and_notify(ids,None,task.creator, do_updates) return "success" From 460f4faafd4f6ec7293433bfefbfd15151c66bf5 Mon Sep 17 00:00:00 2001 From: frimpongopoku Date: Thu, 9 Nov 2023 13:36:26 +0000 Subject: [PATCH 2/2] all coms even when disabled --- src/task_queue/database_tasks/media_library_cleanup.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/task_queue/database_tasks/media_library_cleanup.py b/src/task_queue/database_tasks/media_library_cleanup.py index e635798da..bb221fbc6 100644 --- a/src/task_queue/database_tasks/media_library_cleanup.py +++ b/src/task_queue/database_tasks/media_library_cleanup.py @@ -33,13 +33,12 @@ def remove_duplicate_images(task=None): print("Generating hashes") result = media_store.generate_hashes(None, None, None) - if flag: + if flag and do_updates: communities = flag.enabled_communities() else: communities = Community.objects.all() # task = Task.objects.filter(name="Media Library Cleanup Routine").first() ids = [c.id for c in communities] - print("Here are the ids", ids) clean_and_notify(ids,None,task.creator, do_updates) return "success"