Skip to content

Commit

Permalink
fix(wiper): Delete derived collections first
Browse files Browse the repository at this point in the history
  • Loading branch information
jpmckinney committed Oct 9, 2024
1 parent 8bcc7df commit 73f277c
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions process/management/commands/wiper.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,7 @@ def handle(self, *args, **options):
)


def callback(client_state, channel, method, properties, input_message):
collection_id = input_message["collection_id"]

def delete_collection(collection_id):
tables = [
("record", None), # references collection_file_item
("release", None), # references collection_file_item
Expand Down Expand Up @@ -67,4 +65,20 @@ def callback(client_state, channel, method, properties, input_message):

Collection.objects.filter(pk=collection_id).delete()


def callback(client_state, channel, method, properties, input_message):
collection_id = input_message["collection_id"]

try:
collection = Collection.objects.get(pk=collection_id)
except Collection.DoesNotExist:
pass
else:
if compiled_collection := collection.get_compiled_collection():
delete_collection(compiled_collection.pk)
if upgraded_collection := collection.get_upgraded_collection():
delete_collection(upgraded_collection.pk)

delete_collection(collection_id)

ack(client_state, channel, method.delivery_tag)

0 comments on commit 73f277c

Please sign in to comment.