Skip to content

Commit

Permalink
Merge pull request #2402 from johannaengland/seeddb-vlan
Browse files Browse the repository at this point in the history
Optimize SeedDB vlan listing queries
  • Loading branch information
johannaengland authored May 4, 2022
2 parents a866c20 + 28a6af9 commit cbaaa19
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions python/nav/web/seeddb/page/vlan.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,15 +80,19 @@ class Meta(object):

def vlan_list(request):
info = VlanInfo()
query = Vlan.objects.extra(
select={
'prefixes': (
"array_to_string("
"ARRAY(SELECT netaddr FROM prefix "
"WHERE vlanid=vlan.vlanid), ', ')"
)
}
).all()
query = (
Vlan.objects.extra(
select={
'prefixes': (
"array_to_string("
"ARRAY(SELECT netaddr FROM prefix "
"WHERE vlanid=vlan.vlanid), ', ')"
)
}
)
.select_related("net_type", "organization", "usage")
.all()
)
filter_form = VlanFilterForm(request.GET)
value_list = (
'net_type',
Expand Down

0 comments on commit cbaaa19

Please sign in to comment.