-
Notifications
You must be signed in to change notification settings - Fork 0
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
Support atomic batch deletion #205
Conversation
fb9a7a3
to
f14ffd7
Compare
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.
We need to sort out the "show with multiple ids" situation before we can ship this.
@@ -91,8 +96,34 @@ def prerender_viewmodel(...) | |||
|
|||
private | |||
|
|||
# Viewmodels allow for integer or uuid ids |
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.
Is this the first time we've formalized this requirement?
We could defer the id serializer to the controller, which would avoid encoding this requirement and be more precise about the particular id type in use. The cost of this, of course, is in integration complexity which is already very high.
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 think it's been implicit up to now. The only reason I'm adding it here is because I couldn't straightforwardly make an ArrayOf.new(Anything)
. That said, I think it would be just fine and sufficient to say "Array of Integer or String" and not have any further constraints, which would effectively be the same as before. Maybe that would be better.
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 loosened the restriction back to integer-or-string
def viewmodel_id | ||
parse_param(:id) | ||
parse_param(:id, with: ViewmodelIdSerializer) |
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.
Do we explicitly support fetch by multiple id? We have clients that make use of this, and either it works because the backend doesn't enforce types and thus viewmodel_id is already sometimes an array, or it doesn't work and the clients somehow don't hit that call path.
I think show should support fetch by multiple id. Perhaps you can do so by copy/pasting the viewmodel_ids
parser from delete
?
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.
We explicitly support index
filtered by multiple id, by having a default :id
array-typed request filter defined. I think that's a more natural place for it than introducing a new route "show, but show for specific set".
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.
We explicitly support index filtered by multiple id, by having a default :id array-typed request filter defined.
Alright, things won't break, 👍.
Awkward that superficially similar concerns are implemented in entirely different layers and code bases, but that's not a reason to hold this back. I'm not even sure we can do better.
We could conceivably pull the request filtering framework out of the application into the gem. The main challenge I think would be factoring it out so that the |
FYI I was successfully able to use the new |
@chrisandreae Random thought: The frontend currently sends the list of IDs via query params when making a It's probably technically possible to send a body with a |
Another random thought: How will this work for controllers that override the |
I think it's like GET with body: Rails allows it and it should just work on the server side, but it's more a question of (a) will the frontend make it hard to do, and (b) will any intermediary HTTP caches get in the way. Rails/Rack also has a built-in work-around for this issue: you can make a
It's this one: when we update the app to use this library version, we'll want to make sure that all the places we override |
The VM::AR controller destroy action now optionally parses multiple ids for deletion, and the action is aliased as a collection route as well as a member route. Deletion is performed one at a time within the same transaction.
1daadd2
to
e83af52
Compare
I haven't looked into whether or not it would be hard to make a |
The VM::AR controller destroy action now optionally parses multiple ids for
deletion, and the action is aliased as a collection route as well as a member
route.
Deletion is performed one at a time within the same transaction.