Beispiel #1
0
class Vectors(db.Model):
    __tablename__ = 'vectors'
    word = db.Column(db.String(), primary_key=True, unique=True)
    vector = db.Column(db.String(), nullable=False)

    def __init__(self, word, vector):
        self.word = word
        self.vector = vector
Beispiel #2
0
class Rating(db.Model):
    __tablename__ = 'ratings'
    rating_id = db.Column(db.Integer, primary_key=True)
    rating = db.Column(db.Integer, nullable=False)
    rating_date = db.Column(db.DateTime(timezone=True), default=func.now())
    item_id = db.Column(db.Integer, db.ForeignKey('items.audio_id'))
    user_id = db.Column(db.Integer, db.ForeignKey('users.id'))

    def __init__(self, rating):
        self.rating = rating
Beispiel #3
0
class User(db.Model, UserMixin):
    # Create a table in the db
    __tablename__ = 'users'
    id = db.Column(db.Integer, primary_key=True)
    what_user_likes = db.Column(db.String())
    authors_user_likes = db.Column(db.String())
    user_rating = db.relationship('Rating', backref='user')
    user_recommendation = db.relationship('Recommendations', backref='user')

    def __init__(self, id):
        self.id = id

    def check_password(self, password):
        # https://stackoverflow.com/questions/23432478/flask-generate-password-hash-not-constant-output
        return check_password_hash(self.password_hash, password)
Beispiel #4
0
class Recommendations(db.Model):
    __tablename__ = 'recommendations'
    recommendation_id = db.Column(db.Integer, primary_key=True)
    rating_date = db.Column(db.DateTime, default=datetime.utcnow)
    audio_id = db.Column(db.Integer, nullable=False)
    title = db.Column(db.String(), nullable=False)
    url = db.Column(db.String(), nullable=False)
    explanations = db.Column(db.String(), nullable=False)
    teaser = db.Column(db.String(), nullable=False)
    broadcast_date = db.Column(db.DateTime, nullable=False)
    duration = db.Column(db.Float(), nullable=False)
    user_id = db.Column(db.Integer, db.ForeignKey('users.id'))

    def __init__(self, audio_id, title, url, explanations, teaser,
                 broadcast_date, duration, user_id):
        self.audio_id = audio_id
        self.title = title
        self.url = url
        self.explanations = explanations
        self.teaser = teaser
        self.broadcast_date = broadcast_date
        self.duration = duration
        self.user_id = user_id
Beispiel #5
0
class Item(db.Model):
    __tablename__ = 'items'
    audio_id = db.Column(db.Integer, primary_key=True)
    title = db.Column(db.String(), nullable=False)
    url = db.Column(db.String(), nullable=False)
    small_picture_url = db.Column(db.String(), nullable=False)
    big_picture_url = db.Column(db.String(), nullable=False)
    vector = db.Column(db.String(), nullable=False)
    preprocess = db.Column(db.String(), nullable=False)
    nouns = db.Column(db.String(), nullable=False)
    teaser = db.Column(db.String(), nullable=False)
    broadcast_date = db.Column(db.DateTime, nullable=False)
    duration = db.Column(db.Float(), nullable=False)
    authors = db.Column(db.String())
    item_rating = db.relationship('Rating', backref='item', lazy='dynamic')

    def __init__(self, audio_id, title, url, small_picture_url,
                 big_picture_url, vector, preprocess, nouns, teaser, duration,
                 broadcast_date, authors):
        self.audio_id = audio_id
        self.title = title
        self.url = url
        self.small_picture_url = small_picture_url
        self.big_picture_url = big_picture_url
        self.vector = vector
        self.preprocess = preprocess
        self.nouns = nouns
        self.teaser = teaser
        self.broadcast_date = broadcast_date
        self.duration = duration
        self.authors = authors

    def __repr__(self):
        return f"Titel: {self.title} hat die ID {self.audio_id}"