Move Coalesce into get_subquery function and rename function to get_related_count #4365

Closed
opened 2025-12-29 18:35:14 +01:00 by adam · 3 comments
Owner

Originally created by @DanSheps on GitHub (Dec 16, 2020).

Originally assigned to: @jeremystretch on GitHub.

Proposed Changes

  • Move the Coalescence from the serializer into the get_subquery function
  • Rename function from get_subquery() to get_related_count()

Justification

Since the get_subquery function is only used for annotating a count, it would make sense to add the Coalescence into the function instead of on each instance of get_subquery.

Renaming the function will better describe the purpose of the function.

Originally created by @DanSheps on GitHub (Dec 16, 2020). Originally assigned to: @jeremystretch on GitHub. ### Proposed Changes * Move the Coalescence from the serializer into the get_subquery function * Rename function from get_subquery() to get_related_count() ### Justification Since the get_subquery function is only used for annotating a count, it would make sense to add the Coalescence into the function instead of on each instance of get_subquery. Renaming the function will better describe the purpose of the function.
adam added the status: acceptedtype: housekeeping labels 2025-12-29 18:35:14 +01:00
adam closed this issue 2025-12-29 18:35:14 +01:00
Author
Owner

@jeremystretch commented on GitHub (Dec 16, 2020):

While we're at it, should we rename get_subquery() to something that better conveys its purpose? It's only ever used to return a count of related objects: Maybe get_related_count() or something similar?

@jeremystretch commented on GitHub (Dec 16, 2020): While we're at it, should we rename `get_subquery()` to something that better conveys its purpose? It's only ever used to return a count of related objects: Maybe `get_related_count()` or something similar?
Author
Owner

@DanSheps commented on GitHub (Dec 16, 2020):

I definitely think that would be a good idea

I will add that to the scope

@DanSheps commented on GitHub (Dec 16, 2020): I definitely think that would be a good idea I will add that to the scope
Author
Owner

@jeremystretch commented on GitHub (Dec 17, 2020):

Implemented in 91083fd6c5 and 4a066a1913

@jeremystretch commented on GitHub (Dec 17, 2020): Implemented in 91083fd6c52f11a4af163be1978b9a75d66ea639 and 4a066a191318799a48b4e5380feea6774e4ea8fe
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#4365