-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Prefetch interface data for REST API on netbox 4.2 #18826
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
Prefetch interface data for REST API on netbox 4.2 #18826
Conversation
|
I see that I've missed |
|
I remove loaded data cache invalidation, so the current logic of updating |
|
@Tishka17 I've been testing this and the performance gains do look good. I'm seeing similar query and timing numbers to yours in fetching interfaces/peers/path_objects etc, and the data looks to be the same as before. A couple of questions though, mostly just around organization:
Thanks for your patience! |
|
… into fix/generic_prefetch_4.2
`GenericArrayForeignKey`, which was added in #18826, advertised itself as a many_to_many relation, which is somewhat inaccurate and triggered DRF's introspection of many_to_many relations which looks for a `remote_field.model` property chain on the relation. Since that doesn't exist, DRF threw an AttributeError resulting in a 500 error. This changes `GenericArrayForeignKey` to advertise itself to DRF as a one_to_many relation, which is more accurate, and does not trigger the property access in DRF that was causing the problem. This also adds a regression test for both FrontPort and RearPort "path" API view.
Fixes: #18409
CabledObjectModel.link_peersCablePath._get_pathmethod_pathandcable