plan 추가, analysis 오탈자 제거
This commit is contained in:
1 parent
eec682b02c
commit
602c69543c
11 files changed
+440
-43
No files matched your search
+31
-1
@@ -154,6 +154,34 @@ async def save_gangnam_unni_raw_data(row_id: int, data: dict) -> None:
|
||||
await execute("UPDATE gangnam_unni_data SET raw_data = %s, status = 'done' WHERE id = %s", (json.dumps(data, ensure_ascii=False), row_id))
|
||||
|
||||
|
||||
async def _insert_hospital_history(hospital_id: str, analysis_run_id: str | None) -> None:
|
||||
row = await fetchone(
|
||||
"SELECT owner_user_id, hospital_name, hospital_name_en, brn, road_address, site_address, url, status, raw_data"
|
||||
" FROM hospital_baseinfo WHERE hospital_id = %s",
|
||||
(hospital_id,),
|
||||
)
|
||||
if not row:
|
||||
return
|
||||
await execute(
|
||||
"INSERT INTO hospital_history"
|
||||
" (hospital_id, owner_user_id, hospital_name, hospital_name_en, brn, road_address, site_address, url, status, raw_data, analysis_run_id)"
|
||||
" VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
|
||||
(
|
||||
hospital_id,
|
||||
row["owner_user_id"],
|
||||
row["hospital_name"],
|
||||
row["hospital_name_en"],
|
||||
row["brn"],
|
||||
row["road_address"],
|
||||
row["site_address"],
|
||||
row["url"],
|
||||
row["status"],
|
||||
row["raw_data"] if isinstance(row["raw_data"], str) else json.dumps(row["raw_data"], ensure_ascii=False) if row["raw_data"] else None,
|
||||
analysis_run_id,
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
async def insert_hospital(
|
||||
hospital_id: str,
|
||||
name: str,
|
||||
@@ -172,13 +200,14 @@ async def insert_hospital(
|
||||
json.dumps(raw_data, ensure_ascii=False) if raw_data else None,
|
||||
owner_user_id, brn),
|
||||
)
|
||||
await _insert_hospital_history(hospital_id, analysis_run_id=None)
|
||||
return await fetchone(
|
||||
"SELECT created_at FROM hospital_baseinfo WHERE hospital_id = %s",
|
||||
(hospital_id,),
|
||||
)
|
||||
|
||||
|
||||
async def save_hospital_raw_data(hospital_id: str, data: dict) -> None:
|
||||
async def save_hospital_raw_data(hospital_id: str, data: dict, analysis_run_id: str | None = None) -> None:
|
||||
await execute(
|
||||
"UPDATE hospital_baseinfo"
|
||||
" SET raw_data = %s, status = 'done',"
|
||||
@@ -194,3 +223,4 @@ async def save_hospital_raw_data(hospital_id: str, data: dict) -> None:
|
||||
hospital_id,
|
||||
),
|
||||
)
|
||||
await _insert_hospital_history(hospital_id, analysis_run_id)
|
||||
Reference in new issue
Block a user