Commit da8e95a3 authored by Tomas Taraba's avatar Tomas Taraba

3386 Add column property to return associated user count

parent 75433eed
......@@ -14,9 +14,12 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <>
from sqlalchemy import select, func
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.helpers.db_manager import Base
......@@ -29,3 +32,7 @@ class Labels(Base):
id = Column(Integer, nullable=False, autoincrement=True)
display_name = Column(String(128), nullable=False, unique=True)
description = Column(Text)
user_features = relationship("UserFeatures", secondary="userlabels", back_populates="labels")
users_count = column_property(select([func.count(]))
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