def forwards(self, orm):
        from drawquest.apps.drawquest_auth.models import User
        from canvas.redis_models import redis

        completed_user_ids = [int(e) for e in redis.smembers('following_migration_completed_user_ids')]

        for user in User.objects.all():
            if user.id in completed_user_ids:
                continue

            print user.username,

            followers = user.redis.followers.smembers()
            followers = User.objects.filter(id__in=followers).order_by('username').values_list('id', flat=True)

            for id_ in reversed(followers):
                user.redis.new_followers.bump(id_)

            following = user.redis.followers.smembers()
            following = User.objects.filter(id__in=following).order_by('username').values_list('id', flat=True)

            for id_ in reversed(following):
                user.redis.new_following.bump(id_)

            redis.sadd('following_migration_completed_user_ids', user.id)

        redis.delete('following_migration_completed_user_ids')

        print
示例#2
0
def preload_explore_comment_ids():
    redis.delete('explore_comment_ids_temp')

    ids = explore_comment_ids()

    for id_ in ids:
        redis.sadd('explore_comment_ids_temp', id_)

    if ids:
        redis.rename('explore_comment_ids_temp', 'explore_comment_ids')
示例#3
0
def preload_explore_comment_ids():
    redis.delete('explore_comment_ids_temp')

    ids = explore_comment_ids()

    for id_ in ids:
        redis.sadd('explore_comment_ids_temp', id_)

    if ids:
        redis.rename('explore_comment_ids_temp', 'explore_comment_ids')
    def forwards(self, orm):
        from drawquest.apps.drawquest_auth.models import User
        from drawquest.apps.drawquest_auth.details_models import UserDetails
        from canvas.redis_models import redis

        completed_user_ids = [
            int(e)
            for e in redis.smembers('following_migration_completed_user_ids')
        ]
        try:
            highest_completed = max(completed_user_ids)
        except ValueError:
            highest_completed = 0

        all_users = User.objects.all()
        print 'Gathering all_usernames...'
        all_usernames = dict(
            (int(id_), username.lower())
            for id_, username in all_users.values_list('id', 'username'))
        print 'Done'
        print 'Beginning all_users iteration...'

        for user in all_users.filter(id__gte=highest_completed):
            if user.id in completed_user_ids:
                print 'Skipping {}'.format(user.id)
                continue

            print user.username, '({})'.format(user.id)

            followers = user.redis.followers.smembers()
            ids = sorted(followers,
                         key=lambda f: all_usernames.get(int(f), 'fff'))
            for f in reversed(ids):
                user.redis.new_followers.bump(f)

            user.redis.new_following.zremrangebyrank(0, -1)
            following = user.redis.following.smembers()
            ids = sorted(following,
                         key=lambda f: all_usernames.get(int(f), 'fff'))
            for f in reversed(ids):
                user.redis.new_following.bump(f)

            redis.sadd('following_migration_completed_user_ids', user.id)

        redis.delete('following_migration_completed_user_ids')

        print
    def forwards(self, orm):
        from drawquest.apps.drawquest_auth.models import User
        from drawquest.apps.drawquest_auth.details_models import UserDetails
        from canvas.redis_models import redis

        completed_user_ids = [int(e) for e in redis.smembers('following_migration_completed_user_ids')]
        try:
            highest_completed = max(completed_user_ids)
        except ValueError:
            highest_completed = 0

        all_users = User.objects.all()
        print 'Gathering all_usernames...'
        all_usernames = dict((int(id_), username.lower()) for id_, username in all_users.values_list('id', 'username'))
        print 'Done'
        print 'Beginning all_users iteration...'

        for user in all_users.filter(id__gte=highest_completed):
            if user.id in completed_user_ids:
                print 'Skipping {}'.format(user.id)
                continue

            print user.username, '({})'.format(user.id)

            followers = user.redis.followers.smembers()
            ids = sorted(followers, key=lambda f: all_usernames.get(int(f), 'fff'))
            for f in reversed(ids):
                user.redis.new_followers.bump(f)

            user.redis.new_following.zremrangebyrank(0, -1)
            following = user.redis.following.smembers()
            ids = sorted(following, key=lambda f: all_usernames.get(int(f), 'fff'))
            for f in reversed(ids):
                user.redis.new_following.bump(f)

            redis.sadd('following_migration_completed_user_ids', user.id)

        redis.delete('following_migration_completed_user_ids')

        print
示例#6
0
    def forwards(self, orm):
        from drawquest.apps.drawquest_auth.models import User
        from canvas.redis_models import redis

        completed_user_ids = [
            int(e)
            for e in redis.smembers('following_migration_completed_user_ids')
        ]

        for user in User.objects.all():
            if user.id in completed_user_ids:
                continue

            print user.username,

            followers = user.redis.followers.smembers()
            followers = User.objects.filter(
                id__in=followers).order_by('username').values_list('id',
                                                                   flat=True)

            for id_ in reversed(followers):
                user.redis.new_followers.bump(id_)

            following = user.redis.followers.smembers()
            following = User.objects.filter(
                id__in=following).order_by('username').values_list('id',
                                                                   flat=True)

            for id_ in reversed(following):
                user.redis.new_following.bump(id_)

            redis.sadd('following_migration_completed_user_ids', user.id)

        redis.delete('following_migration_completed_user_ids')

        print