示例#1
0
def get_target(content_id):
    """
    get the last social shares from database
    """
    data = SocialShare.get_last_social_shares_by_content_id(content_id)
    if not data:
        return
    return data.facebook_shares + data.retweets + data.upvotes
示例#2
0
def get_target(content_id):
    """
    get the last social shares from database
    """
    data = SocialShare.get_last_social_shares_by_content_id(content_id)
    if not data:
        return
    return data.facebook_shares + data.retweets + data.upvotes
示例#3
0
def populate_social_shares():
    contents = Content.query.all()
    print contents[0]
    print "updating social shares"
    for i in contents:
        if i.get_shares_count() <= 3:
            data = social_count(i.url)
            social_share = SocialShare.createSocialShare(db.session, data['facebook_shares'], data['retweets'],
                                                        data['upvotes'])
            social_share.content = i
            db.session.commit()

        share_count = max([share.facebook_shares + share.retweets + share.upvotes for share in i.socialShares])
        i.rank = score(share_count, i.timestamp)
        db.session.commit()
示例#4
0
def get_social_feature(content_id=0, content_data=''):
    """
    @todo: separate fb, twitter, reddit
    """
    social_dict = {}
    num_shares = 0

    #get data
    if content_id:
        data = SocialShare.get_first_social_shares_by_content_id(content_id)
        if not data:
            return {}
        num_shares = data.facebook_shares + data.retweets + data.upvotes
    elif content_data:
        num_shares = content_data
    if not num_shares:
        return {}

    #extract feature
    social_dict['shares_num'] = num_shares

    return social_dict
示例#5
0
def get_social_feature(content_id=0, content_data=''):
    """
    @todo: separate fb, twitter, reddit
    """
    social_dict = {}
    num_shares = 0

    #get data
    if content_id:
        data = SocialShare.get_first_social_shares_by_content_id(content_id)
        if not data:
            return {}
        num_shares = data.facebook_shares + data.retweets + data.upvotes
    elif content_data:
        num_shares = content_data
    if not num_shares:
        return {}

    #extract feature
    social_dict['shares_num'] = num_shares

    return social_dict
示例#6
0
def get_social_share(url):
    social_share = SocialShare()
    social_share.facebook_shares = get_facebook_shares(url)
    social_share.retweets = get_twitter_retweets(url)
    social_share.upvotes = get_reddit_upvotes(url)
    return social_share
示例#7
0
def get_social_share(url):
    social_share = SocialShare()
    social_share.facebook_shares = get_facebook_shares(url)
    social_share.retweets = get_twitter_retweets(url)
    social_share.upvotes = get_reddit_upvotes(url)
    return social_share