Closed rye closed 9 years ago
This seems rather clean, actually, now that I've checked the custom bulk creation methods.
I'd really like @Sammidysam's evaluation of this.
FReCon::Controller.team_number_to_team_id
and FReCon::Controller.match_number_and_competition_to_match_id
don't seem to work with this recursive stuff yet.
Ah, yes, I understand them not working. You should make them not do anything if the thing is an array.
Should I just make those return a recursive map of the data (call the method recursively on each item in post_data
if it is an Array?).
Oh wait, no, your suggestion is better.
Yeah, it'll be called on each through the create
recursion.
Will RecordsController.create
call itself recursively? Is that how super
methods work?
super
in RecordsController.create
calls Controller.create
.
Anyway, comments from my "evaluation": I like it. This is about how I would have done it. :+1:
All right. Anything glaring that I should change?
Just add return post_data unless post_data.is_a?(Hash)
to the beginning of the two controller methods that convert post_data, then :shipit:
Oh, didn't see your comment. Yes.
You can just look for an error in the results array.
An error would be anything other than 201?
I believe so. But you have to account for return values often being an array, and then checking the first element in the subarray.
Yes, I know. I'll just map each of the arrays to their first elements, then compare the count of the selection of all non-201 codes to 0. If any non-201 codes exist, then I'll make it return 400.
All right. I'll F.I.:shipit: now.
This is horribly messy, and I think there should be some better way to do it. However, it works in isolated cases, when given a JSON array of teams, for example.