# -*- coding: utf-8 -*-
# Generated by Django 1.9.13 on 2019-04-08 12:29
from __future__ import unicode_literals

from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

    dependencies = [
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
        ('problems', '0011_auto_20190312_1517'),
    ]

    operations = [
        migrations.CreateModel(
            name='ProblemStatistics',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('submitted', models.IntegerField(default=0, verbose_name='attempted solutions')),
                ('solved', models.IntegerField(default=0, verbose_name='correct solutions')),
                ('avg_best_score', models.IntegerField(default=0, verbose_name='average result')),
                ('_best_score_sum', models.IntegerField(default=0)),
                ('problem', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, related_name='statistics', to='problems.Problem')),
            ],
        ),
        migrations.CreateModel(
            name='UserStatistics',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('has_submitted', models.BooleanField(default=False, verbose_name='user submitted')),
                ('has_solved', models.BooleanField(default=False, verbose_name='user solved')),
                ('best_score', models.IntegerField(default=0, verbose_name="user's best score")),
                ('problem_statistics', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='problems.ProblemStatistics')),
                ('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
            ],
        ),
        migrations.AddField(
            model_name='problemstatistics',
            name='user_statistics',
            field=models.ManyToManyField(through='problems.UserStatistics', to=settings.AUTH_USER_MODEL),
        ),
        migrations.AlterUniqueTogether(
            name='userstatistics',
            unique_together=set([('problem_statistics', 'user')]),
        ),
    ]
