Skip to content

Commit

Permalink
nit #11570
Browse files Browse the repository at this point in the history
  • Loading branch information
chrabyrd committed Nov 8, 2024
1 parent 1638ecb commit 6abb19a
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions arches/app/models/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
from copy import deepcopy
from django.core.exceptions import ObjectDoesNotExist
from django.db import transaction, connection
from django.db.models import OuterRef, Subquery
from django.db.utils import IntegrityError
from arches.app.const import IntegrityCheck
from arches.app.models import models
Expand Down Expand Up @@ -2747,13 +2746,15 @@ def update_from_editable_future_graph(self):
graph_from_database.create_editable_future_graph()

# TODO: This is a temporary fix to remove nodegroups that are no longer in use. It should be replaced with a more performant solution.
models.NodeGroup.objects.filter(
~models.Q(
pk__in=Subquery(
models.Node.objects.values("pk").filter(pk=OuterRef("pk"))
)
with connection.cursor() as cursor:
cursor.execute(
"""
DELETE FROM node_groups
WHERE NOT EXISTS (
SELECT 1 FROM nodes WHERE nodes.nodeid = node_groups.nodegroupid
);
"""
)
).delete()

return graph_from_database

Expand Down

0 comments on commit 6abb19a

Please sign in to comment.