Skip to content

Commit

Permalink
67 remove sources without shapes (#74)
Browse files Browse the repository at this point in the history
* mgm-cmd to clean up remove sources without shapes #67
closes remove not used adm-units #55

* again ...
  • Loading branch information
csae8092 authored Jul 27, 2024
1 parent f894b93 commit 5b3edd5
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions shps/management/commands/cleanup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
from django.core.management.base import BaseCommand

from shps.models import Source
from vocabs.models import SkosConcept


class Command(BaseCommand):

help = """Removes objects without relations (Sources and ADMs)"""

def handle(self, *args, **options):
no_shps = Source.objects.filter(source_of=None)
print(f"found {no_shps.count()} Sources without shapes")
no_shps.delete()
print("deleted Sources without shapes")
print("delete not used SkosConcepts")
no_shps = SkosConcept.objects.filter(adm_unit=None).filter(
narrower_concepts=None
)
print(f"found {no_shps.count()} Vocabs without shapes and children")
no_shps.delete()
print("done")
return "done"

0 comments on commit 5b3edd5

Please sign in to comment.