You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Getting the prefixes related to an IP address is a bit cumbersome as we need to loop over each prefixes and get the corresponding prefixes. This impacts readability and performance.
I can work on a PR, but I would like to know first if this modification is even wanted.
I didn't find any discussion/PR/Issue related to this proposal, but I did find multiple issues that would be solved by this implementation.
For example #3099
Implementation idea
The easiest way I found (theoretically) would be to:
Create a PostgresQL view (using a migration script and RunSQL command)
Define an intermediate Model and specify the "table_db"
Reference the intermediate model in a Many2ManyField with the "through" field.
NOTE:
The relationship in the view would be sorted by IPaddress and then by Prefixes. This way, we would easily get the hierarchy of parent prefixes.
We could create a subview (i.e. depending on the first one) that contains only the direct parent. This would be easily done considering the first one is already sorted.
If this is successful, we could do the same for the IPRanges
Benefits
Would reduce the number of queries needed to retrieve the related objects
Would allow batch operations e.g.
"Retrieve all IPAddresses that are inside one of these Prefixes"
NOTE: This specific example isn't the hardest as we could use SubQuery
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Getting the prefixes related to an IP address is a bit cumbersome as we need to loop over each prefixes and get the corresponding prefixes. This impacts readability and performance.
I can work on a PR, but I would like to know first if this modification is even wanted.
I didn't find any discussion/PR/Issue related to this proposal, but I did find multiple issues that would be solved by this implementation.
For example #3099
Implementation idea
The easiest way I found (theoretically) would be to:
NOTE:
Benefits
"Retrieve all IPAddresses that are inside one of these Prefixes"
NOTE: This specific example isn't the hardest as we could use SubQuery
Beta Was this translation helpful? Give feedback.
All reactions