Netbox: API count shows count of all aggregate tagged items and not count of tags

Created on 4 Jun 2019  路  6Comments  路  Source: netbox-community/netbox

Environment

  • Python version: 3.5.2
  • NetBox version: 2.5.13

Steps to Reproduce

  1. Browse to: https://NetBoxURL/extras/tags, see count of tags (ex: 25)
  2. Browse to: https://NetBoxURL/api/extras/tags, see count which is an aggregate of all tagged items, rather then the count of distinct tags in NetBox

Expected Behavior

API count of tags should match the WebUI and the API

Observed Behavior

API count of tags doesn't match the WebUI, or the behavior of count variable on other API endpoints.

accepted bug

All 6 comments

Confirmed this is still present.

This looks to be to do with some performance optimizations made in the Pagination class.

If my understanding is correct the count in /api/extras/tags should show the number of distinct tags like in /extras/tags.

I can take this, except if @pm17788 you want to work on this fix.

@KhaledTo : Sadly, my Python-Fu is still weak. Still learning, so I'm not ready to go committing code yet.

Looks like I fixed a slightly different problem under #3116.

FYI this has already been fixed under develop-2.6. The root issue stems from the use of distinct=True when annotating the TaggedItem count on the queryset. In v2.6, we've started using subqueries instead.

Not sure it makes sense to backport this utility function to the v2.5 train but we should be able to do a one-off implementation.

@jeremystretch : If it is not too tricky to make into 2.5 branch, it'd be awesome. There is some code I'd like to roll out internally, and can't, because of this silly thing :(

Closing this out as v2.6 is being released today.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

markve-sa picture markve-sa  路  4Comments

luto picture luto  路  3Comments

bellwood picture bellwood  路  3Comments

Grokzen picture Grokzen  路  3Comments

hellerve picture hellerve  路  3Comments