from django.shortcuts import render
import pandas as pd
import pickle, os
from pathlib import Path
BASE_DIR = Path(__file__).resolve().parent.parent

# Create your views here.
def indexPage(request):
    return render(request, 'index.html', {})

def proj1Page(request):
    data_desc = pd.read_csv('/home/heeju/PROJECT_KDT/data/desc.csv')
    col_desc = pd.read_csv('/home/heeju/PROJECT_KDT/data/col_desc.csv')
    kill_counts = pd.read_csv('/home/heeju/PROJECT_KDT/data/killCounts.csv')
    outlier_rate_tier = pd.read_csv('/home/heeju/PROJECT_KDT/data/outlier_rate_tier.csv')
    outlier_rate_type = pd.read_csv('/home/heeju/PROJECT_KDT/data/outlier_rate_type.csv')
    etc_per_kills = pd.read_csv('/home/heeju/PROJECT_KDT/data/etc_per_kills.csv')
    numGroups_matchDuration = pd.read_csv('/home/heeju/PROJECT_KDT/data/numGroups_matchDuration.csv')
    numGroups_matchDuration_squad = pd.read_csv('/home/heeju/PROJECT_KDT/data/numGroups_matchDuration_squad.csv')
    numGroups_matchDuration_duo = pd.read_csv('/home/heeju/PROJECT_KDT/data/numGroups_matchDuration_duo.csv')
    numGroups_matchDuration_solo = pd.read_csv('/home/heeju/PROJECT_KDT/data/numGroups_matchDuration_solo.csv')
    numGroups_matchDuration_bronze = pd.read_csv('/home/heeju/PROJECT_KDT/data/numGroups_matchDuration_bronze.csv')
    numGroups_matchDuration_silver = pd.read_csv('/home/heeju/PROJECT_KDT/data/numGroups_matchDuration_silver.csv')
    numGroups_matchDuration_gold = pd.read_csv('/home/heeju/PROJECT_KDT/data/numGroups_matchDuration_gold.csv')
    numGroups_matchDuration_platinum = pd.read_csv('/home/heeju/PROJECT_KDT/data/numGroups_matchDuration_platinum.csv')
    numGroups_matchDuration_diamond = pd.read_csv('/home/heeju/PROJECT_KDT/data/numGroups_matchDuration_diamond.csv')
    numGroups_matchDuration_master = pd.read_csv('/home/heeju/PROJECT_KDT/data/numGroups_matchDuration_master.csv')
    kill_winPlacePerc_squad = pd.read_csv('/home/heeju/PROJECT_KDT/data/kill_winPlacePerc_squad.csv')
    kill_winPlacePerc_duo = pd.read_csv('/home/heeju/PROJECT_KDT/data/kill_winPlacePerc_duo.csv')
    kill_winPlacePerc_solo = pd.read_csv('/home/heeju/PROJECT_KDT/data/kill_winPlacePerc_solo.csv')
    kill_winPlacePerc_bronze = pd.read_csv('/home/heeju/PROJECT_KDT/data/kill_winPlacePerc_bronze.csv')
    kill_winPlacePerc_silver = pd.read_csv('/home/heeju/PROJECT_KDT/data/kill_winPlacePerc_silver.csv')
    kill_winPlacePerc_gold = pd.read_csv('/home/heeju/PROJECT_KDT/data/kill_winPlacePerc_gold.csv')
    kill_winPlacePerc_platinum = pd.read_csv('/home/heeju/PROJECT_KDT/data/kill_winPlacePerc_platinum.csv')
    kill_winPlacePerc_diamond = pd.read_csv('/home/heeju/PROJECT_KDT/data/kill_winPlacePerc_diamond.csv')
    kill_winPlacePerc_master = pd.read_csv('/home/heeju/PROJECT_KDT/data/kill_winPlacePerc_master.csv')
    with open('/home/heeju/PROJECT_KDT/data/reg_flat.pkl', 'rb') as f:
        data_flat = pickle.load(f)
    with open('/home/heeju/PROJECT_KDT/data/kill_boxplot.pkl', 'rb') as f:
        kill_boxplot = pickle.load(f)
    data_flat['desc_column'] = data_desc.columns.tolist()
    data_flat['desc'] = data_desc.values.tolist()
    data_flat['col_desc_column'] = col_desc.columns.tolist()
    data_flat['col_desc'] = col_desc.values.tolist()
    data_flat['kills'] = kill_counts['kills'].values.tolist()
    data_flat['kill_counts'] = kill_counts['count'].values.tolist()
    data_flat['kill_boxplot'] = kill_boxplot
    data_flat['etc_kills'] = etc_per_kills['kills'].values.tolist()
    data_flat['winPlacePerc'] = etc_per_kills['winPlacePerc'].values.tolist()
    data_flat['assists'] = etc_per_kills['assists'].values.tolist()
    data_flat['DBNOs'] = etc_per_kills['DBNOs'].values.tolist()
    data_flat['damageDealt'] = etc_per_kills['damageDealt'].values.tolist()
    data_flat['numGroups_matchDuration_columns'] = numGroups_matchDuration['numGroups'].values.tolist()
    data_flat['numGroups_matchDuration'] = numGroups_matchDuration['matchDuration'].values.tolist()
    data_flat['numGroups_matchDuration_squad_columns'] = numGroups_matchDuration_squad['numGroups'].values.tolist()
    data_flat['numGroups_matchDuration_squad'] = numGroups_matchDuration_squad['matchDuration'].values.tolist()
    data_flat['numGroups_matchDuration_duo_columns'] = numGroups_matchDuration_duo['numGroups'].values.tolist()
    data_flat['numGroups_matchDuration_duo'] = numGroups_matchDuration_duo['matchDuration'].values.tolist()
    data_flat['numGroups_matchDuration_solo_columns'] = numGroups_matchDuration_solo['numGroups'].values.tolist()
    data_flat['numGroups_matchDuration_solo'] = numGroups_matchDuration_solo['matchDuration'].values.tolist()
    data_flat['numGroups_matchDuration_bronze_column'] = numGroups_matchDuration_bronze['numGroups'].values.tolist()
    data_flat['numGroups_matchDuration_bronze'] = numGroups_matchDuration_bronze['matchDuration'].values.tolist()
    data_flat['numGroups_matchDuration_silver_column'] = numGroups_matchDuration_silver['numGroups'].values.tolist()
    data_flat['numGroups_matchDuration_silver'] = numGroups_matchDuration_silver['matchDuration'].values.tolist()
    data_flat['numGroups_matchDuration_gold_column'] = numGroups_matchDuration_gold['numGroups'].values.tolist()
    data_flat['numGroups_matchDuration_gold'] = numGroups_matchDuration_gold['matchDuration'].values.tolist()
    data_flat['numGroups_matchDuration_platinum_column'] = numGroups_matchDuration_platinum['numGroups'].values.tolist()
    data_flat['numGroups_matchDuration_platinum'] = numGroups_matchDuration_platinum['matchDuration'].values.tolist()
    data_flat['numGroups_matchDuration_diamond_column'] = numGroups_matchDuration_diamond['numGroups'].values.tolist()
    data_flat['numGroups_matchDuration_diamond'] = numGroups_matchDuration_diamond['matchDuration'].values.tolist()
    data_flat['numGroups_matchDuration_master_column'] = numGroups_matchDuration_master['numGroups'].values.tolist()
    data_flat['numGroups_matchDuration_master'] = numGroups_matchDuration_master['matchDuration'].values.tolist()
    data_flat['kill_winPlacePerc_solo_column'] = kill_winPlacePerc_solo['kills'].values.tolist()
    data_flat['kill_winPlacePerc_solo'] = kill_winPlacePerc_solo['winPlacePerc'].values.tolist()
    data_flat['kill_winPlacePerc_duo_column'] = kill_winPlacePerc_duo['kills'].values.tolist()
    data_flat['kill_winPlacePerc_duo'] = kill_winPlacePerc_duo['winPlacePerc'].values.tolist()
    data_flat['kill_winPlacePerc_squad_column'] = kill_winPlacePerc_squad['kills'].values.tolist()
    data_flat['kill_winPlacePerc_squad'] = kill_winPlacePerc_squad['winPlacePerc'].values.tolist()
    data_flat['kill_winPlacePerc_bronze_column'] = kill_winPlacePerc_bronze['kills'].values.tolist()
    data_flat['kill_winPlacePerc_bronze'] = kill_winPlacePerc_bronze['winPlacePerc'].values.tolist()
    data_flat['kill_winPlacePerc_silver_column'] = kill_winPlacePerc_silver['kills'].values.tolist()
    data_flat['kill_winPlacePerc_silver'] = kill_winPlacePerc_silver['winPlacePerc'].values.tolist()
    data_flat['kill_winPlacePerc_gold_column'] = kill_winPlacePerc_gold['kills'].values.tolist()
    data_flat['kill_winPlacePerc_gold'] = kill_winPlacePerc_gold['winPlacePerc'].values.tolist()
    data_flat['kill_winPlacePerc_platinum_column'] = kill_winPlacePerc_platinum['kills'].values.tolist()
    data_flat['kill_winPlacePerc_platinum'] = kill_winPlacePerc_platinum['winPlacePerc'].values.tolist()
    data_flat['kill_winPlacePerc_diamond_column'] = kill_winPlacePerc_diamond['kills'].values.tolist()
    data_flat['kill_winPlacePerc_diamond'] = kill_winPlacePerc_diamond['winPlacePerc'].values.tolist()
    data_flat['kill_winPlacePerc_master_column'] = kill_winPlacePerc_master['kills'].values.tolist()
    data_flat['kill_winPlacePerc_master'] = kill_winPlacePerc_master['winPlacePerc'].values.tolist()
    data_flat['outlier_rate_tier_column'] = outlier_rate_tier['tier'].values.tolist()
    data_flat['outlier_rate_tier'] = outlier_rate_tier['rate'].values.tolist()
    data_flat['outlier_rate_type_column'] = outlier_rate_type['type'].values.tolist()
    data_flat['outlier_rate_type'] = outlier_rate_type['rate'].values.tolist()

    return render(request, 'proj1.html', data_flat)