示例#1
0
class Channel(Base):
    id = db.Column(db.Integer, primary_key=True)
    type = db.Column(db.Integer, index=True)
    page_id = db.Column(db.String(40), index=True, unique=True)
    page_name = db.Column(db.String(50), index=True)
    followers = db.Column(db.Integer)
    following = db.Column(db.Integer)
    description = db.Column(db.Text)
    website = db.Column(db.String(50))
    phone = db.Column(db.String(30))
    admin = db.Column(db.Boolean, default=False)
    influencer = db.Column(db.Boolean, default=False, index=True)

    def __init__(self, type, page_id, page_name, followers, following,
                 description, website, phone, admin, influencer):
        self.type = type
        self.page_id = page_id
        self.page_name = page_name
        self.followers = followers
        self.following = following
        self.description = description
        self.website = website
        self.phone = phone
        self.admin = admin
        self.influencer = influencer

    def __repr__(self):
        return '<%s %s %s %s %s %s %s %s %s %s %s>' % (
            self.id, self.type, self.page_id, self.page_name, self.followers,
            self.following, self.description, self.website, self.phone,
            self.admin, self.influencer)
示例#2
0
class Like(Base):
    id = db.Column(db.Integer, primary_key=True)
    post_id = db.Column(db.String(40),
                        db.ForeignKey('post.post_id'),
                        index=True)
    user_id = db.Column(db.String(40), index=True)
    user_name = db.Column(db.String(200))

    def __init__(self, post_id, user_id, user_name):
        self.post_id = post_id
        self.user_id = user_id
        self.user_name = user_name

    def __repr__(self):
        return '<%s %s %s>' % (self.post_id, self.user_id, self.user_name)
示例#3
0
class Photo(Base):
    id = db.Column(db.Integer, primary_key=True)
    post_id = db.Column(db.String(40),
                        db.ForeignKey('post.post_id'),
                        index=True)
    photo_desc = db.Column(db.Text)
    photo = db.Column(db.String(900), index=True)

    def __init__(self, post_id, photo_desc, photo):
        self.post_id = post_id
        self.photo_Desc = photo_desc
        self.photo = photo

    def __repr__(self):
        return '<%s %s %s>' % (self.post_id, self.photo_desc, self.photo)
示例#4
0
class Post(Base):
    id = db.Column(db.Integer, primary_key=True)
    post_id = db.Column(db.String(40), unique=True)
    post_type = db.Column(db.String(10), index=True)
    post_created_time = db.Column(db.DateTime(timezone=True), index=True)
    post_content = db.Column(db.Text)
    post_link = db.Column(db.String(700))
    post_likes = db.Column(db.Integer, index=True)
    post_comments = db.Column(db.Integer, index=True)
    post_shares = db.Column(db.Integer, index=True)
    post_photos = db.Column(db.ARRAY(db.String(500)))
    page_id = db.Column(db.Integer, db.ForeignKey('channel.id'), index=True)
    hashtags = db.relationship('Hash',
                               secondary=association_tags,
                               backref=db.backref('posts', lazy='dynamic'))

    def __init__(self, post_id, post_type, post_created_time, post_content,
                 post_link, post_likes, post_comments, post_shares,
                 post_photos, page_id):
        self.post_id = post_id
        self.post_type = post_type
        self.post_created_time = post_created_time
        self.post_content = post_content
        self.post_link = post_link
        self.post_likes = post_likes
        self.post_comments = post_comments
        self.post_shares = post_shares
        self.post_photos = post_photos
        self.page_id = page_id

    @hybrid_property
    def get_hash(self):
        hashtag_list = list({
            i.strip("#")
            for i in self.__getattribute__('post_content').split()
            if i.startswith("#")
        })
        return hashtag_list

    def __repr__(self):
        return '<%s %s %s %s %s %s %s %s %s %s >' % (
            self.post_id, self.post_type, self.post_created_time,
            self.post_content, self.post_link, self.post_likes,
            self.post_comments, self.post_shares, self.post_photos,
            self.page_id)
示例#5
0
class Hash(Base):
    id = db.Column(db.Integer, primary_key=True, index=True)
    hashtag = db.Column(db.String(50), index=True, unique=True)

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

    def __repr__(self):
        return '<%s %s>' % (self.id, self.hashtag)
示例#6
0
class Comment(Base):
    id = db.Column(db.Integer, primary_key=True)
    post_id = db.Column(db.String(40),
                        db.ForeignKey('post.post_id'),
                        index=True)
    user_id = db.Column(db.String(40), index=True)
    user_name = db.Column(db.String(800))
    user_message = db.Column(db.Text)

    def __init__(self, post_id, user_id, user_name, user_message,
                 user_created_time):
        self.post_id = post_id
        self.user_id = user_id
        self.user_name = user_name
        self.user_message = user_message
        self.user_created_time = user_created_time

    def __repr__(self):
        return '<%s %s %s %s %s>' % (self.post_id, self.user_id,
                                     self.user_name, self.user_message,
                                     self.user_created_time)
示例#7
0
class User(Base):
    id = db.Column(db.Integer, primary_key=True)
    user_id = db.Column(db.String(40), index=True)
    user_name = db.Column(db.String(40))
    user_screen_name = db.Column(db.String(40))
    user_description = db.Column(db.Text)
    user_photo = db.Column(db.Text)
    page_id = db.Column(db.String(50),
                        db.ForeignKey('channel.page_id'),
                        index=True)

    def __init__(self, user_id, user_name, user_screen_name, user_description,
                 user_photo, page_id):
        self.user_id = user_id
        self.user_name = user_name
        self.user_screen_name = user_screen_name
        self.user_description = user_description
        self.user_photo = user_photo
        self.page_id = page_id

    def __repr__(self):
        return '<%s %s %s %s %s %s>' % (
            self.user_id, self.user_name, self.user_screen_name,
            self.user_description, self.user_photo, self.page_id)
示例#8
0
class PostInsight(Base):
    id = db.Column(db.Integer, primary_key=True)
    post_id = db.Column(db.String(40),
                        db.ForeignKey('post.post_id'),
                        index=True)
    post_impressions = db.Column(db.Integer, index=True)
    post_consumptions = db.Column(db.Integer, index=True)
    post_impressions_unique = db.Column(db.Integer, index=True)

    def __init__(self, post_id, post_impressions, post_consumptions,
                 post_impressions_unique):
        self.post_id = post_id
        self.post_impressions = post_impressions
        self.post_consumptions = post_consumptions
        self.post_impressions_unique = post_impressions_unique

    def __repr__(self):
        return '<%s %s %s %s>' % (self.post_id, self.post_impressions,
                                  self.post_consumptions,
                                  self.post_impressions_unique)