-
Notifications
You must be signed in to change notification settings - Fork 5
fix issue with nested cardinality n tiles not doing a clean delete #152
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev/1.0.x
Are you sure you want to change the base?
Conversation
jacobtylerwalls
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Howdy howdy. Thought you wouldn't mind having a couple notes, hope it helps!
| delete_missing_tiles = ( | ||
| self.request.GET.get("delete_missing_tiles", "").lower() == "true" | ||
| ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tl;dr this should already be stored as self.partial (should have been self.is_partial_update or self.leave_missing_children_alone, I guess).
The goal was always to push requests out the model layer entirely. It's here as a concession to support legacy post tile save functions. If you need this in a hurry, hopefully we can capture a follow-up to remove it?
If you're writing your own views, then you can parse args exactly how you like. If you're using the framework, here is where the view layer passes down arguments to the save method's partial= arg.
arches-querysets/arches_querysets/rest_framework/view_mixins.py
Lines 166 to 168 in ff194ef
| # Freeze some keyword arguments to the model save() method. | |
| is_partial_update = self.request.method == "PATCH" | |
| ret.save = partial(ret.save, request=self.request, partial=is_partial_update) |
Looking at this now, partial=... is a terrible name given it's rhyming with functools.partial here.
(Is that spooky action at a distance? I guess. The tradeoff being action at a distance versus having to remember to call save() different ways in different views. And the idea being you could always write your own view if you got tired of doing it the framework-way, but otherwise try to provide reasons not to write your own view.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, I'm not familiar with what request.GET looks like on put/patch requests, does it still give you querystring args? So it does!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks @jacobtylerwalls I'll look into the self.partial property. I think we'll still need to have the abilty to pass in a querystring param (which btw, works on PUT and PATCH requests just like it does for GETs), to allow users to opt in/out of tile deletes.
| if tile._state.adding: | ||
| tile.set_missing_keys_to_none() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wasn't clear on how much of an error condition this was to have missing keys; I thought we had a lot of knockout code that errored out pretty hard on them. Is the idea to gate this for inserts only, so that we take a "light touch" with existing tiles?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll have to look into this again. This check may be rendered useless now that a more final fix is in place. I think at first this was causing an issue.
|
|
||
| for tile in incoming_tiles: | ||
| if tile in self.to_delete: | ||
| # Need to remove tiles flagged for deletion if they are |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ouch. I'd love to hear a little bit more about what you found here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missing pairs of tile id's from _pair_tiles cause this issue becuase they are considered "deleted" when in fact on a subsequent loop through the code those "deleted" tiles are in fact being updated.
Honestly, there is probably a deeper refactor required here that our budget just can't afford.
…tiles" querystring param isn't supplied, re #151
chrabyrd
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
code looks good, haven't given it a spin yet. 1 nit 😁
| grouping_node.alias | ||
| ]: | ||
| if str(existing_tile.nodegroup_id) in self.deletable_nodegroups: | ||
| # print( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice 😄
No description provided.