Commit 1a347e6c authored by Tomas Taraba's avatar Tomas Taraba

3386 Fix the correct labels user count query

parent 8e5d4ee9
......@@ -19,7 +19,7 @@ from sqlalchemy.orm import relationship, column_property
from sqlalchemy.schema import Column, PrimaryKeyConstraint
from sqlalchemy.types import Integer, String, Text
from xivo_dao.alchemy.userfeatures import UserFeatures
from xivo_dao.alchemy import UserLabels
from xivo_dao.helpers.db_manager import Base
......@@ -35,4 +35,8 @@ class Labels(Base):
user_features = relationship("UserFeatures", secondary="userlabels", back_populates="labels")
users_count = column_property(select([func.count(UserFeatures.id)]))
users_count = column_property(
select([func.count(UserLabels.id)])
.where(UserLabels.label_id == id)
.correlate_except(UserLabels)
)
......@@ -37,6 +37,8 @@ class TestLabelExist(DAOTestCase):
assert_that(result, equal_to(True))
def test_get_all_labels(self):
self.add_user(callerid='"John Doe"')
label_row = self.add_label()
result = label_dao.search()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment