From ecf6daa0e9bc30c634e51615237517f85a888f9d Mon Sep 17 00:00:00 2001 From: bill-becker Date: Sun, 15 Sep 2024 22:04:25 -0600 Subject: [PATCH] Avoid Site db update if not needed --- julia_src/http.jl | 4 ++-- reoptjl/src/process_results.py | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/julia_src/http.jl b/julia_src/http.jl index 69ef1ee94..6af9762ac 100644 --- a/julia_src/http.jl +++ b/julia_src/http.jl @@ -121,11 +121,11 @@ function reopt(req::HTTP.Request) inputs_with_defaults_set_in_julia = Dict( "Financial" => Dict(key=>getfield(model_inputs.s.financial, key) for key in inputs_with_defaults_from_easiur), "ElectricUtility" => Dict(key=>getfield(model_inputs.s.electric_utility, key) for key in inputs_with_defaults_from_avert_or_cambium), + "Site" => site_dict, "CHP" => chp_dict, "SteamTurbine" => steamturbine_dict, "GHP" => ghp_dict, - "ExistingChiller" => chiller_dict, - "Site" => site_dict, + "ExistingChiller" => chiller_dict ) catch e @error "Something went wrong in REopt optimization!" exception=(e, catch_backtrace()) diff --git a/reoptjl/src/process_results.py b/reoptjl/src/process_results.py index 4650903cc..87dc6a824 100644 --- a/reoptjl/src/process_results.py +++ b/reoptjl/src/process_results.py @@ -121,7 +121,9 @@ def update_inputs_in_database(inputs_to_update: dict, run_uuid: str) -> None: # get input models that need updating FinancialInputs.objects.filter(meta__run_uuid=run_uuid).update(**inputs_to_update["Financial"]) ElectricUtilityInputs.objects.filter(meta__run_uuid=run_uuid).update(**inputs_to_update["ElectricUtility"]) - SiteInputs.objects.filter(meta__run_uuid=run_uuid).update(**inputs_to_update["Site"]) + + if inputs_to_update["Site"]: + SiteInputs.objects.filter(meta__run_uuid=run_uuid).update(**inputs_to_update["Site"]) if inputs_to_update["CHP"]: # Will be an empty dictionary if CHP is not considered CHPInputs.objects.filter(meta__run_uuid=run_uuid).update(**inputs_to_update["CHP"])