from snek.model.user import UserModel
from snek.system.mapper import BaseMapper


class UserMapper(BaseMapper):
    table_name = "user"
    model_class = UserModel

    def get_admin_uids(self):
        try:
            return [
                user["uid"]
                for user in self.db.query(
                    "SELECT uid FROM user WHERE is_admin = :is_admin",
                    {"is_admin": True},
                )
            ]
        except Exception as ex:
            print(ex)
            return []
