Beispiel #1
0
class ReportedUsers(db.Model):
    __tablename__ = 'reported_users'

    id = db.Column(db.Integer, primary_key=True)
    reporter_user_id = db.Column(db.Integer,
                                 db.ForeignKey('user.id', ondelete='CASCADE'))
    reported_user_id = db.Column(db.Integer,
                                 db.ForeignKey('user.id', ondelete='CASCADE'))
    reported_at = db.Column(db.DateTime(timezone=True))
    reason = db.Column(db.String)
    reporter = db.relationship('User', foreign_keys=[reporter_user_id])
    reported = db.relationship('User', foreign_keys=[reported_user_id])
Beispiel #2
0
class User(db.Model):
    __tablename__ = 'user'

    id = db.Column(db.Integer, primary_key=True)
    created = db.Column(db.DateTime(timezone=True), default=datetime.utcnow)
    musicbrainz_id = db.Column(db.String)
    auth_token = db.Column(db.String)
    last_login = db.Column(db.DateTime(timezone=True), default=datetime.utcnow, nullable=False)
    latest_import = db.Column(db.DateTime(timezone=True), default=lambda: datetime.fromutctimestamp(0))
    gdpr_agreed = db.Column(db.DateTime(timezone=True))
    musicbrainz_row_id = db.Column(db.Integer, nullable=False)
    login_id = db.Column(db.String)
Beispiel #3
0
class Spotify(db.Model):
    __tablename__ = 'spotify_auth'

    user_id = db.Column(db.Integer,
                        db.ForeignKey('user.id', ondelete='CASCADE'),
                        primary_key=True)
    user_token = db.Column(db.String, nullable=False)
    token_expires = db.Column(db.DateTime(timezone=True))
    refresh_token = db.Column(db.String, nullable=False)
    last_updated = db.Column(db.DateTime(timezone=True))
    latest_listened_at = db.Column(db.DateTime(timezone=True))
    record_listens = db.Column(db.Boolean, default=True)
    error_message = db.Column(db.String)
    permission = db.Column(db.String, nullable=False)
Beispiel #4
0
class ListensImporter(db.Model):
    __tablename__ = 'listens_importer'

    id = db.Column(db.Integer, primary_key=True)
    external_service_oauth_id = db.Column(db.Integer, db.ForeignKey('external_service_oauth.id', ondelete='SET NULL'))
    user_id = db.Column(db.Integer, db.ForeignKey('user.id', ondelete='CASCADE'), nullable=False)
    # Workaround: cannot use Enum here because it seems SQLAlchemy uses the variable names of the enum instead of
    # the values assigned to them. It is possible to write a wrapper to change this behaviour but for our purposes
    # just using a string works fine so not going into that.
    service = db.Column(db.String, nullable=False)
    last_updated = db.Column(db.DateTime(timezone=True))
    latest_listened_at = db.Column(db.DateTime(timezone=True))
    error_message = db.Column(db.String)
    user = db.relationship('User')
class ExternalService(db.Model):
    __tablename__ = 'external_service_oauth'

    id = db.Column(db.Integer, primary_key=True)
    user_id = db.Column(db.Integer,
                        db.ForeignKey('user.id', ondelete='CASCADE'),
                        nullable=False)
    # Workaround: cannot use Enum here because it seems SQLAlchemy uses the variable names of the enum instead of
    # the values assigned to them. It is possible to write a wrapper to change this behaviour but for our purposes
    # just using a string works fine so not going into that.
    service = db.Column(db.String, nullable=False)
    access_token = db.Column(db.String, nullable=False)
    refresh_token = db.Column(db.String)
    token_expires = db.Column(db.DateTime(timezone=True))
    last_updated = db.Column(db.DateTime(timezone=True),
                             server_default=db.func.now())
    scopes = db.Column(db.ARRAY(db.String))
    user = db.relationship('User')
class PlaylistRecording(db.Model):
    __bind_key__ = "timescale"
    __tablename__ = "playlist_recording"
    __table_args__ = {"schema": "playlist"}

    id = db.Column(db.Integer, autoincrement=True, primary_key=True)
    playlist_id = db.Column(db.Integer,
                            db.ForeignKey("playlist.playlist.id",
                                          ondelete="CASCADE"),
                            nullable=False)
    position = db.Column(db.Integer, nullable=False)
    mbid = db.Column(UUID(as_uuid=True), nullable=False)
    added_by_id = db.Column(db.Integer, nullable=False)
    created = db.Column(db.DateTime(timezone=True), nullable=False)

    def __str__(self):
        return str(self.mbid)
Beispiel #7
0
class Playlist(db.Model):
    __bind_key__ = "timescale"
    __tablename__ = "playlist"
    __table_args__ = {"schema": "playlist"}

    id = db.Column(db.Integer, autoincrement=True, primary_key=True)
    mbid = db.Column(UUID(as_uuid=True), nullable=False)
    creator_id = db.Column(db.Integer, nullable=False)
    name = db.Column(db.String, nullable=False)
    description = db.Column(db.String)
    public = db.Column(db.Boolean, nullable=False)
    created = db.Column(db.DateTime(timezone=True), nullable=False)
    last_updated = db.Column(db.DateTime(timezone=True), nullable=False)
    copied_from_id = db.Column(db.Integer)
    created_for_id = db.Column(db.Integer)
    algorithm_metadata = db.Column(JSONB)

    recordings = db.relationship("PlaylistRecording", backref="playlist")

    def __str__(self):
        return self.name