# Path: washmap/washmap/chart_constants.py
# SANITATION_COLOR_RANGE = ["#d45500", "#da670f", "#eb7e1f", "#eb941f", "#ebb01f", "#f2c83d", "#d3cc4f", "#86c26f", "#4db181", "#15b598"]
# 
# WATER_COLOR_RANGE = ["#8c9494", "#8398a2", "#7c9baa", "#73a1b4", "#6aa6bd", "#62abc7", "#5aafd0", "#52b4d9", "#49bae4", "#3fc0f0"]
# 
# GRAY = "#CCCCCC"


from pandas import DataFrame
from numpy import where
from country.models import Country
from main.utils import build_coords_lists
from stats.models import StatValue
from .chart_constants import SANITATION_COLOR_RANGE, WATER_COLOR_RANGE, GRAY


def get_wat_stats_all_years():
    wat_stats_df = get_stats_from_model('WNTI_%', 'wat_value')
    return wat_stats_df


def get_san_stats_all_years():
    san_stats_df = get_stats_from_model('SNTI_%', 'san_value')
    return san_stats_df


def get_data_with_countries(wat_stats_df, san_stats_df, year=1990):
    countries_df = get_countries()

    # Get data for year, Merge water & sanitation
    wat_stats_df = wat_stats_df[wat_stats_df.year == year]
    san_stats_df = san_stats_df[san_stats_df.year == year]
    wat_san_df = wat_stats_df.merge(san_stats_df)

    # Merge the countries and stats together
    merged_df = countries_df.merge(wat_san_df, how='left')
    merged_df = merged_df.fillna(value=-99)

    # Color it
    colored_df = color_data(merged_df)
    colored_df['year'] = year

    # Otherwise things are sad!
    colored_df.columns = colored_df.columns.astype('str')

# Path: washmap/washmap/chart_constants.py
# SANITATION_COLOR_RANGE = ["#d45500", "#da670f", "#eb7e1f", "#eb941f", "#ebb01f", "#f2c83d", "#d3cc4f", "#86c26f", "#4db181", "#15b598"]
# 
# WATER_COLOR_RANGE = ["#8c9494", "#8398a2", "#7c9baa", "#73a1b4", "#6aa6bd", "#62abc7", "#5aafd0", "#52b4d9", "#49bae4", "#3fc0f0"]
# 
# GRAY = "#CCCCCC"


# Path: washmap/washmap/map_data.py
from pandas import DataFrame
from numpy import where
from country.models import Country
from main.utils import build_coords_lists
from stats.models import StatValue
from .chart_constants import SANITATION_COLOR_RANGE, WATER_COLOR_RANGE, GRAY



def get_wat_stats_all_years():
    wat_stats_df = get_stats_from_model('WNTI_%', 'wat_value')
    return wat_stats_df


def get_san_stats_all_years():
    san_stats_df = get_stats_from_model('SNTI_%', 'san_value')
    return san_stats_df


def get_data_with_countries(wat_stats_df, san_stats_df, year=1990):
    countries_df = get_countries()

    # Get data for year, Merge water & sanitation
    wat_stats_df = wat_stats_df[wat_stats_df.year == year]
    san_stats_df = san_stats_df[san_stats_df.year == year]
    wat_san_df = wat_stats_df.merge(san_stats_df)

    # Merge the countries and stats together
    merged_df = countries_df.merge(wat_san_df, how='left')
    merged_df = merged_df.fillna(value=-99)

    # Color it
    colored_df = color_data(merged_df)
    colored_df['year'] = year

    # Otherwise things are sad!
    colored_df.columns = colored_df.columns.astype('str')

    return colored_df