Skip to content

Commit

Permalink
update_or_create fixes issue without throttling request
Browse files Browse the repository at this point in the history
  • Loading branch information
chiatt committed Sep 26, 2024
1 parent d98b840 commit b23ec43
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 13 deletions.
4 changes: 1 addition & 3 deletions arches/app/media/js/views/graph-designer.js
Original file line number Diff line number Diff line change
Expand Up @@ -308,9 +308,7 @@ define([
}
else {
viewModel.cardTree.updateCards(viewModel.selectedNode().nodeGroupId(), data.responseJSON);
setTimeout(function () {
viewModel.permissionTree.updateCards(viewModel.selectedNode().nodeGroupId(), data.responseJSON);
}, 50);
viewModel.permissionTree.updateCards(viewModel.selectedNode().nodeGroupId(), data.responseJSON);
viewModel.updatedCardinalityData([data.responseJSON, viewModel.graphSettingsViewModel]);
}

Expand Down
16 changes: 6 additions & 10 deletions arches/app/models/card.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,17 +157,13 @@ def __init__(self, *args, **kwargs):
node_id = widget.get("node_id", None)
card_id = widget.get("card_id", None)
widget_id = widget.get("widget_id", None)

try:
widget_model = models.CardXNodeXWidget.objects.get(
node_id=node_id, card_id=card_id
widget_model, _ = (
models.CardXNodeXWidget.objects.update_or_create(
node_id=node_id,
card_id=card_id,
defaults={"widget_id": uuid.UUID(widget_id)},
)
except models.CardXNodeXWidget.DoesNotExist:
widget_model = models.CardXNodeXWidget()
widget_model.node_id = node_id
widget_model.card_id = card_id

widget_model.widget_id = widget_id
)
widget_model.config = widget.get("config", {})
widget_model.label = widget.get("label", "")
widget_model.visible = widget.get("visible", None)
Expand Down

0 comments on commit b23ec43

Please sign in to comment.