peeringdb / peeringdb

Server code for https://www.peeringdb.com/
BSD 2-Clause "Simplified" License
362 stars 112 forks source link

Add carrier_count to fac object #1640

Open arnoldnipper opened 4 months ago

arnoldnipper commented 4 months ago

Describe the bug The field carrier_count is missing from the fac object

To Reproduce

curl -sG https://www.peeringdb.com/api/fac/2148 | jq '.data[] | .carrier_count, .ix_count, .net_count' | paste - - -
null    2       12

However, https://www.peeringdb.com/carrier/512 is in that facilitiy

Expected behavior

Show all counters

jackcarrozzo commented 2 months ago

Do we really need extra _count fields when the sets themselves are returned in the data?

curl -s https://www.peeringdb.com/api/fac/2148 |jq '{nets: .data[].org.net_set|length, carriers: .data[].org.carrier_set|length, facs: .data[].org.fac_set|length, ixs: .data[].org.ix_set|length}'
{
  "nets": 1,
  "carriers": 1,
  "facs": 1,
  "ixs": 0
}

EDIT: ah, I see what you mean- net_set has only one entry but net_count is 12.

mcmanuss8 commented 2 months ago

If we use obj_count fields for everything but carrier we should probably do that

jackcarrozzo commented 2 months ago

PC call: @grizz to help figure out the discrepancy between net_set length and net_count, same for ixs.

arnoldnipper commented 2 months ago

Do we really need extra _count fields when the sets themselves are returned in the data?

You don't get sets with depth=0. Hence _count fields are gratuitous information and have been added for exactly that reason. Hence, the answer is "yes".

grizz commented 2 months ago

net_count is off the facility net_set is off the org

jackcarrozzo commented 2 months ago

Ahh makes sense, thx Matt