mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-06-30 13:10:47 +00:00
use correct db session to write to db
This commit is contained in:
parent
aaeb339254
commit
3136d5a0f8
2 changed files with 9 additions and 10 deletions
|
|
@ -27,8 +27,8 @@ from infrastructure.s3.s3_client import S3Client
|
|||
from orchestration.magic_plan_orchestrator import MagicPlanOrchestrator
|
||||
from applications.magic_plan.magic_plan_trigger_request import MagicPlanTriggerRequest
|
||||
|
||||
ADDRESS = "63 Dunkery Road, Wythenshawe, M22 0WR | EPC"
|
||||
HUBSPOT_DEAL_ID = "501851906250"
|
||||
ADDRESS = "20 Larch Way, Bromley, BR2 8DU | Retrofit Assessment"
|
||||
HUBSPOT_DEAL_ID = "500328089833"
|
||||
# ADDRESS = "33 Wallaby Way, Sydney"
|
||||
# HUBSPOT_DEAL_ID = "123456789"
|
||||
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ from backend.app.db.models.uploaded_file import (
|
|||
)
|
||||
from applications.magic_plan.address_matcher import find_matching_plan
|
||||
from infrastructure.postgres.config import PostgresConfig
|
||||
from infrastructure.postgres.engine import make_engine, make_session
|
||||
from infrastructure.postgres.engine import make_engine, transactional_session
|
||||
from infrastructure.s3.s3_client import S3Client
|
||||
from repositories.magic_plan.magic_plan_postgres_repository import (
|
||||
MagicPlanPostgresRepository,
|
||||
|
|
@ -69,13 +69,12 @@ class MagicPlanOrchestrator:
|
|||
logger.info("Successfully save Plan json")
|
||||
|
||||
engine = make_engine(PostgresConfig.from_env(os.environ))
|
||||
session = make_session(engine)
|
||||
|
||||
session.add(uploaded_file)
|
||||
session.flush()
|
||||
MagicPlanPostgresRepository(session).save(
|
||||
plan, cast(int, uploaded_file.id)
|
||||
) # TODO: refactor to use postgres Unit of Work
|
||||
with transactional_session(engine) as session:
|
||||
session.add(uploaded_file)
|
||||
session.flush()
|
||||
MagicPlanPostgresRepository(session).save(
|
||||
plan, cast(int, uploaded_file.id)
|
||||
) # TODO: refactor to use postgres Unit of Work
|
||||
logger.info("Successfully saved Plan to database")
|
||||
|
||||
return plan
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue