Ejemplo n.º 1
0
 def get_website_url(self, obj):
     return 'http://schoolido.lu' + singlecardurl(obj)
Ejemplo n.º 2
0
 def get_website_url(self, obj):
     return 'http://schoolido.lu' + singlecardurl(obj)
Ejemplo n.º 3
0
    def handle(self, *args, **options):

        print 'Delete activities max bonded/max leveled...'
        while models.Activity.objects.filter(Q(message='Max Leveled a card') | Q(message='Max Bonded a card')).count():
            ids = list(models.Activity.objects.filter(Q(message='Max Leveled a card') | Q(message='Max Bonded a card')).values_list('pk', flat=True)[:100])
            total_this = models.Activity.objects.filter(pk__in=ids).delete()
        print 'Done.'

        print 'Delete activities rank in event without ranking...'
        while get_rankevent_withoutranking_queryset().count():
            ids = list(get_rankevent_withoutranking_queryset().values_list('pk', flat=True)[:100])
            total_this = get_rankevent_withoutranking_queryset().filter(pk__in=ids).delete()
        print 'Done.'

        print 'Cache for owned cards activities'
        while get_ownedcardqueryset().count():
            activities_ownedcards = get_ownedcardqueryset()[:500]
            for activity in activities_ownedcards:
                account = activity.ownedcard.owner_account
                # Fix account
                activity.account = account
                # Cache
                activity = activity_cache_account(activity, account)
                activity.message_data = concat_args(unicode(activity.ownedcard.card), activity.ownedcard.stored)
                activity.right_picture_link = singlecardurl(activity.ownedcard.card)
                activity.right_picture = ownedcardimageurl({}, activity.ownedcard)
                activity.save()
            print '.',
            sys.stdout.flush()
        print 'Done.'

        print 'Cache for rank up activities'
        while get_rankupqueryset().count():
            activities_rankup = get_rankupqueryset()[:500]
            for activity in activities_rankup:
                # Cache
                activity = activity_cache_account(activity, activity.account)
                activity.message_data = concat_args(activity.number)
                activity.save()
            print '.',
            sys.stdout.flush()
        print 'Done.'

        print 'Cache for Rank in event activities'
        while get_rankeventqueryset().count():
            activities_rankevent = get_rankeventqueryset()[:500]
            for activity in activities_rankevent:
                # Cache
                activity = activity_cache_account(activity, activity.account)
                activity.message_data = concat_args(activity.eventparticipation.ranking,
                                                    unicode(activity.eventparticipation.event))
                activity.right_picture = eventimageurl({}, activity.eventparticipation.event, english=(activity.account.language != 'JP'))
                activity.right_picture_link = '/events/' + activity.eventparticipation.event.japanese_name + '/'
                activity.save()
            print '.',
            sys.stdout.flush()
        print 'Done.'

        print 'Remove duplicate activities with ownedcards'
        lastSeenId = float('-Inf')
        i = 0
        total_deleted = 0
        while get_duplicateownedcard_queryset()[i:i+500].count():
            activities_ownedcards = get_duplicateownedcard_queryset()[i:i+500]
            for activity in activities_ownedcards:
                if activity.ownedcard_id == lastSeenId:
                    print 'delete', activity
                    activity.delete()
                    total_deleted += 1
                else:
                    lastSeenId = activity.ownedcard_id
                pass
            i += 500
            print '.',
            sys.stdout.flush()
        print 'Done.'