Skip to content

Commit

Permalink
Avoid Site db update if not needed
Browse files Browse the repository at this point in the history
  • Loading branch information
Bill-Becker committed Sep 16, 2024
1 parent f881886 commit ecf6daa
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 2 additions & 2 deletions julia_src/http.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down
4 changes: 3 additions & 1 deletion reoptjl/src/process_results.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"])
Expand Down

0 comments on commit ecf6daa

Please sign in to comment.