# AUTOGENERATED! DO NOT EDIT! File to edit: nbs/03-deployment.ipynb (unless otherwise specified).

__all__ = ['app', 'update_docs']

# Cell
from outage import collation

import typer

# Cell
app = typer.Typer()

# Cell
@app.command()
def update_docs(
    dnos: list=['ukpn', 'ssen', 'wpd', 'sp', 'np', 'enw'],
    postcodes_fp: str='data/postcodes.csv',
    outages_fp: str='docs/data/outages.csv',
    null_threshold: int=1,
    js_template_fp: str='templates/map_js.j2',
    js_docs_fp: str='docs/map.js',
    md_template_fp: str='templates/index_md.j2',
    docs_md_fp: str='docs/index.md'
):
    # Retrieving and parsing outage data
    cleaned_incidents_info = collation.collate_cleaned_incidents_info(dnos=dnos)
    df_outages = collation.get_combined_outages_df(cleaned_incidents_info)
    df_outages = collation.add_outage_longitudes_latitudes(df_outages, postcodes_fp=postcodes_fp, null_threshold=null_threshold)

    # Map generation
    gdf_outages = collation.construct_outages_gdf(df_outages)
    collation.generate_map_js(gdf_outages, js_template_fp=js_template_fp, js_docs_fp=js_docs_fp)

    # Documentation generation
    df_outages_clean = collation.clean_outages_df(df_outages)
    collation.generate_index_md(df_outages_clean, md_template_fp=md_template_fp, docs_md_fp=docs_md_fp)
    df_outages_clean.assign(Incident=df_outages['incident_id']).to_csv(outages_fp, index=False)

    return

# Cell
if __name__ == '__main__' and '__file__' in globals():
    app()