-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Closes: #11507 - Show Prefixes Aggregate and RIR on API view #18935
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
Conversation
* Add `rir` property method to model * Add `aggregate` property method to model * Add `rir` attribute to serializer * Add `aggregate` attribute to serializer * Add test for both rir and aggregate fields on API
Thinking about this, I think there are a few questions to ask before this can be reviewed:
|
Could not figure out a way to get the RIR as part of the aggregate query, so I had to do them separately. |
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.
While innovative, I'm worried the solution involving a custom JSONModelField might be taking us too far into the deep end. The need for a custom model field feels like a very strong signal that we're going about this in the wrong way. This comment especially feels ominous:
Return the actual instantiated model from the fields, minus the models that cannot be worked with
We can pretty easily obtain the PK of the parent aggregate (if any) for each prefix using a subquery, which is half the battle. We just need a way to then manually prefetch the related Aggregate objects and stitch them together in a manner similar to how prefetch_related()
works natively for ForeignKeys.
Have you looked into using using Prefetch objects at all?
I don't disagree here. I personally think the better way to handle this would be through a foreign key relationship.
I didn't look into using The issue is there is no FK relationship and you can't get another object outside of those FK relationships (with the exception of this) outside of a separate query. I think if anything, we would need a specific Relationship on the model which would allow us to enumerate, prefetch and join on these psuedo-relationships similar. I think this might be more work/effort then just simply adding in the proper relationship in the end. |
I am fine with that. |
Closes: #11507 - Show Prefixes Aggregate and RIR on API view
rir
property method to modelaggregate
property method to modelrir
attribute to serializeraggregate
attribute to serializer