Skip to content

Commit

Permalink
Avoid pessimistic exists() query
Browse files Browse the repository at this point in the history
  • Loading branch information
jacobtylerwalls committed Nov 8, 2024
1 parent f7a7f62 commit 46bcf5b
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions arches/app/models/tile.py
Original file line number Diff line number Diff line change
Expand Up @@ -472,14 +472,11 @@ def save(self, *args, **kwargs):
self.check_for_missing_nodes()
self.check_for_constraint_violation()

creating_new_tile = (
models.TileModel.objects.filter(pk=self.tileid).exists() is False
)
edit_type = "tile create" if (creating_new_tile is True) else "tile edit"

if creating_new_tile is False:
existing_model = models.TileModel.objects.get(pk=self.tileid)
else:
existing_model = models.TileModel.objects.filter(pk=self.tileid).first()
creating_new_tile = existing_model is None
edit_type = "tile edit"
if creating_new_tile:
edit_type = "tile create"
self.populate_missing_nodes()

# this section moves the data over from self.data to self.provisionaledits if certain users permissions are in force
Expand Down

0 comments on commit 46bcf5b

Please sign in to comment.