mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-06-08 11:17:27 +00:00
Coordination Hub fallback stores correct file_source in DB 🟩
This commit is contained in:
parent
dc3543ac5f
commit
1e115ba3de
1 changed files with 11 additions and 4 deletions
|
|
@ -60,9 +60,10 @@ class PashubService:
|
|||
else:
|
||||
try:
|
||||
uprn = active_client.get_uprn_by_job_id(job_id)
|
||||
logger.info(f"Failed to access job {job_id} with PasHub credentials")
|
||||
except UnauthorizedError:
|
||||
logger.info(f"Trying CoordinationHub credentials for job {job_id}")
|
||||
logger.info(
|
||||
f"PasHub credentials unauthorized for job {job_id}; retrying with CoordinationHub credentials"
|
||||
)
|
||||
active_client = self._get_coordination_client()
|
||||
uprn = active_client.get_uprn_by_job_id(job_id)
|
||||
|
||||
|
|
@ -85,8 +86,13 @@ class PashubService:
|
|||
|
||||
if uprn or hubspot_deal_id:
|
||||
logger.info("Uploading files to s3")
|
||||
file_source = (
|
||||
FileSourceEnum.PAS_HUB
|
||||
if active_client is self._pashub_client
|
||||
else FileSourceEnum.COORDINATION_HUB
|
||||
)
|
||||
upload_records = self._upload_to_s3_and_update_db(
|
||||
job_files, uprn, hubspot_deal_id
|
||||
job_files, uprn, hubspot_deal_id, file_source
|
||||
)
|
||||
self._save_site_notes(upload_records)
|
||||
|
||||
|
|
@ -108,6 +114,7 @@ class PashubService:
|
|||
job_files: List[str],
|
||||
uprn: Optional[str],
|
||||
hubspot_deal_id: Optional[str],
|
||||
file_source: FileSourceEnum,
|
||||
) -> List[_FileUploadRecord]:
|
||||
if not uprn and not hubspot_deal_id:
|
||||
return []
|
||||
|
|
@ -133,7 +140,7 @@ class PashubService:
|
|||
s3_upload_timestamp=datetime.now(timezone.utc),
|
||||
uprn=int(uprn) if uprn else None,
|
||||
hubspot_deal_id=hubspot_deal_id,
|
||||
file_source=FileSourceEnum.PAS_HUB.value,
|
||||
file_source=file_source.value,
|
||||
file_type=get_file_type_string(filename),
|
||||
)
|
||||
file_paths.append(file_path)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue