<commit_before>"""SQLAlchemy models for users"""


import backend

db = backend.db
GOOGLE_OAUTH_TYPE = "google"


class User(db.Model):
    """A user account for either a learner or a mentor."""
    __tablename__ = 'users'

    id = db.Column(db.Integer, primary_key=True, nullable=False)
    name = db.Column(db.String, nullable=False)
    email = db.Column(db.String, nullable=True)
    description = db.Column(db.String, nullable=True)
    avatar_url = db.Column(db.String, nullable=True)

    oauth_id = db.Column(db.String, nullable=True)
    oauth_type = db.Column(
            db.Enum(GOOGLE_OAUTH_TYPE, name='oauth_types'),
            nullable=True)
    oauth_token = db.Column(db.String, nullable=True)

    missions = db.relationship("Mission", backref="user")
    quests = db.relationship("Quest", backref="user")
    organizations_created = db.relationship("Organization", backref="user")

    @property
    def url(self):
        """URL for the resource."""
        return backend.api.url_for(backend.user_views.User, user_id=self.id)

db.Index('ix_user_oauth', User.oauth_id, User.oauth_type)<commit_msg>unique constraing on oauth identifier fields<commit_after>"""SQLAlchemy models for users"""


import backend

db = backend.db
GOOGLE_OAUTH_TYPE = "google"


class User(db.Model):
    """A user account for either a learner or a mentor."""
    __tablename__ = 'users'

    id = db.Column(db.Integer, primary_key=True, nullable=False)
    name = db.Column(db.String, nullable=False)
    email = db.Column(db.String, nullable=True)
    description = db.Column(db.String, nullable=True)
    avatar_url = db.Column(db.String, nullable=True)

    oauth_id = db.Column(db.String, nullable=True)
    oauth_type = db.Column(
            db.Enum(GOOGLE_OAUTH_TYPE, name='oauth_types'),
            nullable=True)
    oauth_token = db.Column(db.String, nullable=True)

    missions = db.relationship("Mission", backref="user")
    quests = db.relationship("Quest", backref="user")
    organizations_created = db.relationship("Organization", backref="user")

    __table_args__ = (db.UniqueConstraint('oauth_id', 'oauth_type'),)

    @property
    def url(self):
        """URL for the resource."""
        return backend.api.url_for(backend.user_views.User, user_id=self.id)

db.Index('ix_user_oauth', User.oauth_id, User.oauth_type)
{'fraction_non_alphanumeric': 0.13418803418803418, 'fraction_numerical': 0.0, 'mean_word_length': 3.980851063829787, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '2118956', 'n_tokens_mistral': 802, 'n_tokens_neox': 775, 'n_words': 153}