def post_increase_likes(post_id, count):
    from controllers import post_like
    results = db.session.execute(text("""SELECT users.id FROM users JOIN post_likes 
                                                    ON users.id=post_likes.user
                                                WHERE users.monkness in :monkness
                                                    AND post_likes.post=:post_id
                                                    AND post_likes.unliked=false"""),
                                params = {'monkness':[1, 0], 'post_id':post_id}
                                )

    for user in User.query.with_entities('id').filter(  User.monkness.in_([1, 0]),
                                                        ~User.id.in_([row[0] for row in results])
                                                    ).limit(count).all():

        resp = post_like(user.id, post_id)

    return {'count': count}
Exemple #2
0
def post_like(liked_by=f[random.randint(0, len(f) - 1)].id, post_id=p[random.randint(0, len(p) - 1)].id):

    cleanup()
    print post_id
    controllers.post_like(liked_by, post_id)
    print 'Post like passed'