<commit_before>from flask_security import UserMixin, RoleMixin

from app import cache, db
from app.utils.database import CRUDMixin

roles_users = db.Table('roles_users',
                       db.Column('user_id', db.Integer, db.ForeignKey('user.id')),
                       db.Column('role_id', db.Integer, db.ForeignKey('role.id')))


class Role(db.Model, RoleMixin, CRUDMixin):
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(80), unique=True, nullable=False)
    description = db.Column(db.String(255))


class User(db.Model, UserMixin, CRUDMixin):
    id = db.Column(db.Integer, primary_key=True)
    email = db.Column(db.String(255), unique=True, nullable=False)
    password = db.Column(db.String(255), nullable=False)
    active = db.Column(db.Boolean)
    roles = db.relationship('Role', secondary=roles_users,
                            backref=db.backref('users', lazy='dynamic'))
    posts = db.relationship('Post', backref='author', lazy='dynamic')


class Setting(db.Model, CRUDMixin):
    key = db.Column(db.String(100), primary_key=True)
    name = db.Column(db.String(100))
    value = db.Column(db.PickleType, nullable=False)

    @classmethod
    @cache.memoize()
    def as_dict(cls):
        return {setting.key: setting.value for setting in cls.query.all()}<commit_msg>Fix Setting __repr__<commit_after>from flask_security import UserMixin, RoleMixin

from app import cache, db
from app.utils.database import CRUDMixin

roles_users = db.Table('roles_users',
                       db.Column('user_id', db.Integer, db.ForeignKey('user.id')),
                       db.Column('role_id', db.Integer, db.ForeignKey('role.id')))


class Role(db.Model, RoleMixin, CRUDMixin):
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(80), unique=True, nullable=False)
    description = db.Column(db.String(255))


class User(db.Model, UserMixin, CRUDMixin):
    id = db.Column(db.Integer, primary_key=True)
    email = db.Column(db.String(255), unique=True, nullable=False)
    password = db.Column(db.String(255), nullable=False)
    active = db.Column(db.Boolean)
    roles = db.relationship('Role', secondary=roles_users,
                            backref=db.backref('users', lazy='dynamic'))
    posts = db.relationship('Post', backref='author', lazy='dynamic')


class Setting(db.Model, CRUDMixin):
    key = db.Column(db.String(100), primary_key=True)
    name = db.Column(db.String(100))
    value = db.Column(db.PickleType, nullable=False)

    @classmethod
    @cache.memoize()
    def as_dict(cls):
        return {setting.key: setting.value for setting in cls.query.all()}

    def __repr__(self):
        return '<Setting %s>' % self.key
{'fraction_non_alphanumeric': 0.14322438486962907, 'fraction_numerical': 0.012486228424531766, 'mean_word_length': 3.5551839464882944, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7106654', 'n_tokens_mistral': 930, 'n_tokens_neox': 891, 'n_words': 171}