from peewee import (
    IntegerField,
    BooleanField,
    FloatField,
    CharField,
    Model
)

# This table exists because we fetch _all_ shot_chart_detail records,
# even if the game doesn't exist in the game table. So, we stage all
# records in this temporary table, then insert into the main table
# filtering by existing game_ids.


class ShotChartDetailTemp(Model):

    # Autogenerated id column here.

    game_id = IntegerField(index=True, unique=False)

    player_id = IntegerField(unique=False)
    team_id = IntegerField(unique=False)

    game_event_id = IntegerField(null=True)
    period = IntegerField(null=True)
    minutes_remaining = IntegerField(null=True)
    seconds_remaining = IntegerField(null=True)
    event_type = CharField(null=True)
    action_type = CharField(null=True)
    shot_type = CharField(null=True)
    shot_zone_basic = CharField(null=True)
    shot_zone_area = CharField(null=True)
    shot_zone_range = CharField(null=True)
    shot_distance = FloatField(null=True)
    loc_x = IntegerField(null=True)
    loc_y = IntegerField(null=True)
    shot_attempted_flag = BooleanField(null=True)
    shot_made_flag = BooleanField(null=True)
    htm = CharField(null=True)
    vtm = CharField(null=True)

    class Meta:
        db_table = 'shot_chart_detail_temp'
        temporary = True
