Skip to content

Commit

Permalink
feature: distinct and filtering authorizations on agents count for se…
Browse files Browse the repository at this point in the history
…ctor
  • Loading branch information
AlanJaeger committed Dec 11, 2023
1 parent c8b68f6 commit 6a229db
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions chats/apps/sectors/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,17 +120,12 @@ def serialized_ws_data(self):

@property
def agent_count(self):
agents_count = list(
self.queues.annotate(
agents=models.Count(
"authorizations",
filter=models.Q(authorizations__role=1, is_deleted=False),
)
)
.values_list("agents", flat=True)
agents_count = (
self.queues.filter(authorizations__role=1, is_deleted=False)
.values_list("authorizations__permission", flat=True)
.distinct()
.count()
)
agents_count = sum(agents_count)
return agents_count

@property
Expand Down

0 comments on commit 6a229db

Please sign in to comment.