# -*- coding: utf-8 -*-
# Generated by Django 1.10.6 on 2017-04-07 21:52
from __future__ import unicode_literals

from django.db import migrations
import random
import string

from course_work.models import Location, Road, Passenger
from course_work.search_engine import get_route_duration

names = [
    [
        'Alexander',
        'Alexei',
        'Anatoly',
        'Artyom',
        'Boris',
        'Vadim',
        'Valeriy',
        'Vladislav',
        'Grigoriy',
        'Daniil',
        'Denis',
        'Dmitrii',
        'Evgeniy',
        'Egor',
        'Ivan',
        'Ilya',
        'Kirill',
        'Konstantin',
        'Maxim',
        'Michail',
        'Nikita',
        'Nikolay',
        'Oleg',
        'Pavel',
        'Petr',
        'Roman',
        'Ruslan',
        'Sergey',
        'Stanislav',
        'Timur',
        'Yury'
    ],
    [
        'Alexandra',
        'Anastasiya',
        'Anna',
        'Valentina',
        'Viktoriia',
        'Galina',
        'Diana',
        'Ekaterina',
        'Elena',
        'Evgeniya',
        'Zhanna',
        'Irina',
        'Kseniya',
        'Kristina',
        'Larisa',
        'Lubov',
        'Ludmila',
        'Margarita',
        'Marina',
        'Mariya',
        'Nadezhda',
        'Natalya',
        'Oksana',
        'Olga',
        'Polina',
        'Svetlana',
        'Tatyana',
        'Yulia',
        'Yana'
    ]
]

surname = [
    'Abakumov',
    'Abramov',
    'Averin',
    'Agafonov',
    'Azarov',
    'Alexeyev',
    'Andreev',
    'Anisimov',
    'Anosov',
    'Antipov',
    'Arshavin',
    'Astakhov',
    'Babichev',
    'Babykin',
    'Barinov',
    'Bazhenov',
    'Bazarov',
    'Balakin',
    'Beloysov',
    'Vavilov',
    'Vasnetsov',
    'Vakhrushev',
    'Vetrov',
    'Voloshin',
    'Vorontsov',
    'Gavrilov',
    'Gagarin',
    'Gorbunov',
    'Grigoryev',
    'Davydov',
    'Derzhavin',
    'Dmitriev',
    'Yelizarov',
    'Yeltsov',
    'Yermakov',
    'Yermolaev',
    'Zhdanov',
    'Zhilin',
    'Zaytsev',
    'Ivanov',
    'Izmaylov',
    'Ilyin',
    'Kalashnokov',
    'Kalugin',
    'Kupriyanov',
    'Kirillov',
    'Klimov',
    'Kozakov',
    'Kuzmin',
    'Komarov',
    'Krivov',
    'Kurbatov',
    'Lavrentyev',
    'Lavrov',
    'Lebedev',
    'Levin',
    'Lisov',
    'Limonov',
    'Lomonosov',
    'Maksinov',
    'Mamonov',
    'Marinin',
    'Marinov',
    'Markin',
    'Matveev',
    'Medvedev',
    'Migunov',
    'Minayev',
    'Molchanov',
    'Nazarov',
    'Nikitin',
    'Nosov',
    'Ozerov',
    'Orlov',
    'Osminin',
    'Panov',
    'Pelevin',
    'Perevalov',
    'Pogodin',
    'Popov',
    'Repin',
    'Rasputin',
    'Pozhkov',
    'Rodin',
    'Ryabkin',
    'Ryabov',
    'Savrasov',
    'Samarin',
    'Samoylov',
    'Samsonov',
    'Semyonov',
    'Senkin',
    'Suvorov'
]

list_date = ['2017-08-04', '2017-05-01', '2017-08-01']

def gen_passengers(apps, schema_editor):
    locs = Location.objects.all()
    for i in range(2000):
        gender = random.randint(0, 1) #0 - male, 1 - female
        if gender == 0:
            passenger = Passenger(name=random.choice(names[0])+' '+random.choice(surname))
        elif gender == 1:
            passenger = Passenger(name=random.choice(names[1])+' '+random.choice(surname)+'a')
        passenger.start = random.choice(locs)

        while True:
            end = random.choice(locs)
            if end.name != passenger.start.name:
                passenger.end = end
                break

        coef_price = random.randint(0, 2)
        dur = get_route_duration(passenger.start, passenger.end)
        if coef_price == 0 or coef_price == 1:
            passenger.price = dur * 100
        elif coef_price == 2:
            passenger.price = random.randint(1500, 2500)
        passenger.date = random.choice(list_date)
        passenger.save()

class Migration(migrations.Migration):

    dependencies = [ ('course_work', '0002_gen_locations'),
    ]

    operations = [ migrations.RunPython(gen_passengers, reverse_code=migrations.RunPython.noop),
    ]
