Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API count shows count of all aggregate tagged items and not count of tags #3239

Closed
pm17788 opened this issue Jun 4, 2019 · 6 comments
Closed
Labels
status: accepted This issue has been accepted for implementation type: bug A confirmed report of unexpected behavior in the application

Comments

@pm17788
Copy link

pm17788 commented Jun 4, 2019

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.

@DanSheps DanSheps changed the title Please re-open #3116 API count shows count of all aggregate tagged items and not count of tags Jun 4, 2019
@DanSheps
Copy link
Member

DanSheps commented Jun 4, 2019

Confirmed this is still present.

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

@DanSheps DanSheps added status: accepted This issue has been accepted for implementation type: bug A confirmed report of unexpected behavior in the application labels Jun 4, 2019
@KhaledTo
Copy link

KhaledTo commented Jun 4, 2019

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.

@pm17788
Copy link
Author

pm17788 commented Jun 5, 2019

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

@jeremystretch
Copy link
Member

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.

@pm17788
Copy link
Author

pm17788 commented Jun 5, 2019

@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 :(

@jeremystretch
Copy link
Member

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

@lock lock bot locked as resolved and limited conversation to collaborators Jan 16, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
status: accepted This issue has been accepted for implementation type: bug A confirmed report of unexpected behavior in the application
Projects
None yet
Development

No branches or pull requests

4 participants