def user_followers_milestone_notifications(): result = db.session.execute(text('''SELECT distinct uf.followed as user from user_follows uf inner join users u on u.id = uf.followed where u.monkness = -1 and uf.timestamp >= date_sub(now(), interval 1 day) group by uf.followed union SELECT distinct uf.user as user from inflated_stats uf inner join users u on u.id = uf.user where u.monkness = -1 and uf.timestamp >= date_sub(now(), interval 1 day) and uf.follower_count > 0 group by uf.user; ''')) for row in result: check_and_make_milestone('user_followers_milestone', row[0], row[0], util.get_follower_count(row[0]))
def decide_follow_milestone(user_id): check_and_make_milestone('user-followers-milestone', user_id, user_id, util.get_follower_count(user_id))