mirror of
https://github.com/peeringdb/peeringdb.git
synced 2024-05-11 05:55:09 +00:00
Support 202109 (#1064)
* Block registering private ASN ranges * Add a continental region field for facilities #1007 * Incorrect order of search results #232 * Allow users to upload a small logo to their record #346 * Sponsor badge CSS and text translation issues #453 * IXP and Facility summary #18 * poetry relock * linting * add libgcc * lint * bump version to 2.31.0-beta Co-authored-by: Stefan Pratter <stefan@20c.com> Co-authored-by: David Poarch <dpoarch@20c.com>
This commit is contained in:
@@ -24,3 +24,46 @@ def stats():
|
||||
).count(),
|
||||
"automated_nets": Network.handleref.filter(allow_ixp_update=True).count(),
|
||||
}
|
||||
|
||||
|
||||
def get_fac_stats(netfac, ixfac):
|
||||
return {
|
||||
"networks": netfac.filter(status="ok").count(),
|
||||
"ix": ixfac.filter(status="ok").count(),
|
||||
}
|
||||
|
||||
|
||||
def get_ix_stats(netixlan, ixlan):
|
||||
|
||||
peer_count = netixlan.values("network").distinct().filter(status="ok").count()
|
||||
connections_count = netixlan.filter(ixlan=ixlan, status="ok").count()
|
||||
open_peer_count = (
|
||||
netixlan.values("network")
|
||||
.distinct()
|
||||
.filter(network__policy_general="Open", status="ok")
|
||||
.count()
|
||||
)
|
||||
ipv6_percentage = 0
|
||||
total_speed = 0
|
||||
|
||||
try:
|
||||
ipv6_percentage = int(
|
||||
(
|
||||
netixlan.filter(status="ok", ixlan=ixlan, ipaddr6__isnull=False).count()
|
||||
/ netixlan.filter(ixlan=ixlan, status="ok").count()
|
||||
)
|
||||
* 100
|
||||
)
|
||||
except ZeroDivisionError:
|
||||
pass
|
||||
|
||||
for n in netixlan.filter(status="ok", ixlan=ixlan):
|
||||
total_speed += n.speed
|
||||
|
||||
return {
|
||||
"peer_count": peer_count,
|
||||
"connection_count": connections_count,
|
||||
"open_peer_count": open_peer_count,
|
||||
"ipv6_percentage": ipv6_percentage,
|
||||
"total_speed": total_speed,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user