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 6, 2024
1 parent 4f26c7f commit b91835b
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 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"
existing_model = models.TileModel.objects.filter(pk=self.tileid).first()
creating_new_tile = existing_model is None
edit_type = "tile create" if creating_new_tile else "tile edit"

if creating_new_tile is False:
existing_model = models.TileModel.objects.get(pk=self.tileid)
else:
if not creating_new_tile:
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 b91835b

Please sign in to comment.