from django.db import models
from django.utils import timezone


class LeagueStanding(models.Model):
    competition = models.CharField(max_length=100)  # Id
    standing = models.JSONField()

class Textlinks(models.Model):
    name = models.CharField(max_length=200, null=False)
    href = models.CharField(max_length=400, null=True)
    
class AppSettings(models.Model):
    key = models.CharField(max_length=200, null=False)
    value = models.CharField(max_length=400, null=True)
    
class Matches(models.Model):
    match_id = models.CharField(max_length=200, null=False)
    home_team = models.CharField(max_length=400, null=True) # Operate using primary key.
    away_team = models.CharField(max_length=400, null=True)
    is_completed = models.BooleanField(default=False)
    score_home = models.IntegerField(blank=True, null=True)
    score_away = models.IntegerField(blank=True, null=True)
    commencement_time = models.DateTimeField(null=True, blank=True)
    date = models.DateTimeField(default=timezone.now, blank=True)
    competition = models.CharField(max_length=400, null=True)
    isleague = models.BooleanField(default=False)
    season = models.CharField(max_length=400, null=True)
    
    # 1 x 2
    home_win = models.FloatField(null=True, blank=True)
    draw = models.FloatField(null=True, blank=True)
    away_win = models.FloatField(null=True, blank=True)
    bookmaker = models.CharField(max_length=400, null=True)
    
class Predictions(models.Model):
    match_id = models.CharField(max_length=400, null=True)
    tip = models.CharField(max_length=400, null=True)
    competition = models.CharField(max_length=200, null=True)
    odds = models.CharField(max_length=200, null=True)
    commencement_time = models.DateTimeField(default=timezone.now, blank=True)
    date_created = models.DateTimeField(default=timezone.now, blank=True)
    
class UnavailablePredictions(models.Model):
    home_team = models.CharField(max_length=400, null=True) # Operate using primary key.
    away_team = models.CharField(max_length=400, null=True)
    tip = models.CharField(max_length=400, null=True)
    competition = models.CharField(max_length=200, null=True)
    odds = models.CharField(max_length=200, null=True)
    date_created = models.DateTimeField(default=timezone.now, blank=True)
    commencement_time = models.DateTimeField(null=True, blank=True)
    