# Generated by Django 3.1.3 on 2020-12-03 13:13

from django.db import migrations
import datetime

def forwards(apps, schema_editor):
    Ranking = apps.get_model('podminer.Ranking')
    Show = apps.get_model('core.Show')
    RankingHistory = apps.get_model('podminer.RankingHistory')
    PowerRanking = apps.get_model('podminer.PowerRanking')
    cc=0
    for shw in Show.objects.all():
        req=Ranking.objects.filter(show=shw,ranking__lt=21).count()
        PowerRanking(
            show=shw,
            powerranking=req,
            store_url=shw.url,
        ).save()

        cc+=1
        if cc%2000==0:
            print(cc) #to keep track of progress

class Migration(migrations.Migration):

    dependencies = [
        ('podminer', '0012_powerranking'),
    ]

    operations = [
        migrations.RunPython(forwards, migrations.RunPython.noop),
    ]

