Skip to content

Commit

Permalink
fix: more consistent expulsion by suid
Browse files Browse the repository at this point in the history
  • Loading branch information
aaxelb committed Oct 14, 2024
1 parent 86b1a9b commit d696fdf
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
4 changes: 1 addition & 3 deletions share/admin/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
SourceUniqueIdentifier,
)
from trove import digestive_tract
from trove.models import Indexcard


class ShareAdminSite(admin.AdminSite):
Expand Down Expand Up @@ -292,8 +291,7 @@ def reingest(self, request, queryset):
def delete_cards_for_suid(self, request, queryset):
for suid in queryset:
FormattedMetadataRecord.objects.delete_formatted_records(suid)
for _indexcard in Indexcard.objects.filter(source_record_suid__in=queryset):
_indexcard.pls_delete()
digestive_tract.expel_suid(suid)

def get_search_results(self, request, queryset, search_term):
if not search_term:
Expand Down
12 changes: 8 additions & 4 deletions trove/digestive_tract.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,12 +202,17 @@ def expel(from_user: share_db.ShareUser, record_identifier: str):
source_config__source__user=from_user,
identifier=record_identifier,
)
for _suid in _suid_qs:
expel_suid(_suid)


def expel_suid(suid: share_db.SourceUniqueIdentifier):
(
trove_db.SupplementaryIndexcardRdf.objects
.filter(supplementary_suid__in=_suid_qs)
.filter(supplementary_suid=suid)
.delete()
)
for _indexcard in trove_db.Indexcard.objects.filter(source_record_suid__in=_suid_qs):
for _indexcard in trove_db.Indexcard.objects.filter(source_record_suid=suid):
_indexcard.pls_delete()


Expand All @@ -222,8 +227,7 @@ def task__extract_and_derive(task: celery.Task, raw_id: int, urgent=False):
)
_source_config = _raw.suid.source_config
if _source_config.disabled or _source_config.source.is_deleted:
for _indexcard in trove_db.Indexcard.objects.filter(source_record_suid=_raw.suid):
_indexcard.pls_delete()
expel_suid(_raw.suid)
else:
if _raw.mediatype:
_indexcards = extract(_raw, undelete_indexcards=urgent)
Expand Down

0 comments on commit d696fdf

Please sign in to comment.