from pathlib import Path
from etl.epc.property_change_app import get_cleaned
from etl.solar.SolarPhotoSupply import SolarPhotoSupply

DATA_DIRECTORY = Path(__file__).parent / "local_data" / "all-domestic-certificates"


def app():
    """
    This code reads in the EPC data and attempt to produce a reasonable figure for the photo-supply variable, which
    is the following:
    "Percentage of photovoltaic area as a percentage of total roof area. 0% indicates that a Photovoltaic Supply
    is not present in the property."

    When recommending solar, we want to simulate the retrofit by increasing this value from 0, so we need a sensible
    figure to increase this to. This script will pull the data for that, to allow us to try and deduce what
    a sensible figure would be
    :return:
    """

    directories = [entry for entry in DATA_DIRECTORY.iterdir() if entry.is_dir()]
    cleaned_lookup = get_cleaned()

    solar_data_client = SolarPhotoSupply(
        file_directories=directories,
        cleaned_lookup=cleaned_lookup
    )

    solar_data_client.create_dataset()

    solar_data_client.save()
