feat(scada): add calibrated monitoring and incident recovery
This commit is contained in:
@@ -200,12 +200,24 @@ def temporary_project_name(project: str, purpose: str) -> str:
|
||||
@contextmanager
|
||||
def temporary_project_database(project: str, purpose: str):
|
||||
"""Clone one project's runnable model into an isolated temporary database."""
|
||||
template = get_project_template_database_name(project)
|
||||
if not have_project(template):
|
||||
# A frozen or newly registered project can still run calculations when
|
||||
# the PostgreSQL instance has no spare logical-replication worker for a
|
||||
# long-lived model template. Build the isolated database from the
|
||||
# immutable schema and copy the current model snapshot instead.
|
||||
from .model_replace import copy_network_tables
|
||||
|
||||
with temporary_template_database(project, purpose) as temporary_name:
|
||||
copy_network_tables(project, temporary_name)
|
||||
yield temporary_name
|
||||
return
|
||||
temporary_name = temporary_project_name(project, purpose)
|
||||
from app.services.calculation_cleanup import record_calculation_database
|
||||
record_calculation_database(temporary_name)
|
||||
try:
|
||||
copy_project(
|
||||
get_project_template_database_name(project),
|
||||
template,
|
||||
temporary_name,
|
||||
allow_template_source=True,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user