fix: resolve missing preview data in permit import session and fix logging bug
This commit is contained in:
parent
70e46a730e
commit
1595027679
|
|
@ -1710,9 +1710,9 @@ def commit_permit_import_session(
|
||||||
details={
|
details={
|
||||||
"filename": workbook_filename,
|
"filename": workbook_filename,
|
||||||
"sheets_processed": len(sheet_names),
|
"sheets_processed": len(sheet_names),
|
||||||
"created_count": result["created_count"],
|
"created_count": len(result["created_permits"]),
|
||||||
"overwritten_count": result["overwritten_count"],
|
"overwritten_count": len(result["overwritten_permits"]),
|
||||||
"skipped_count": result["skipped_count"],
|
"skipped_count": len(result["skipped_permits"]),
|
||||||
"snapshot_count": result["snapshot_count"]
|
"snapshot_count": result["snapshot_count"]
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
@ -1798,60 +1798,60 @@ def describe_permit_import_session(session_id: str) -> Dict[str, Any]:
|
||||||
|
|
||||||
total_permits += len(permit_summaries)
|
total_permits += len(permit_summaries)
|
||||||
|
|
||||||
theme_options: List[Dict[str, Any]] = []
|
theme_options: List[Dict[str, Any]] = []
|
||||||
seen_theme_labels: Set[str] = set()
|
seen_theme_labels: Set[str] = set()
|
||||||
|
|
||||||
theme_options.append(
|
theme_options.append(
|
||||||
{
|
{
|
||||||
"id": ALL_THEMES_SENTINEL,
|
"id": ALL_THEMES_SENTINEL,
|
||||||
"name": ALL_THEMES_DISPLAY_NAME,
|
"name": ALL_THEMES_DISPLAY_NAME,
|
||||||
"source": "virtual",
|
"source": "virtual",
|
||||||
"description": "选择后将与当前及未来的新主题自动绑定",
|
"description": "选择后将与当前及未来的新主题自动绑定",
|
||||||
"is_all": True,
|
"is_all": True,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
seen_theme_labels.add(ALL_THEMES_SENTINEL.lower())
|
seen_theme_labels.add(ALL_THEMES_SENTINEL.lower())
|
||||||
seen_theme_labels.add(ALL_THEMES_DISPLAY_NAME.lower())
|
seen_theme_labels.add(ALL_THEMES_DISPLAY_NAME.lower())
|
||||||
|
|
||||||
candidate_theme_lists: List[List[Dict[str, str]]] = []
|
candidate_theme_lists: List[List[Dict[str, str]]] = []
|
||||||
region_theme_options = region_theme_map.get(region_id)
|
region_theme_options = region_theme_map.get(region_id)
|
||||||
if region_theme_options:
|
if region_theme_options:
|
||||||
candidate_theme_lists.append(region_theme_options)
|
candidate_theme_lists.append(region_theme_options)
|
||||||
if all_theme_options:
|
if all_theme_options:
|
||||||
candidate_theme_lists.append(all_theme_options)
|
candidate_theme_lists.append(all_theme_options)
|
||||||
|
|
||||||
for option_list in candidate_theme_lists:
|
for option_list in candidate_theme_lists:
|
||||||
for option in option_list:
|
for option in option_list:
|
||||||
label = option.get("name") or ""
|
label = option.get("name") or ""
|
||||||
normalized = label.lower()
|
normalized = label.lower()
|
||||||
if normalized in seen_theme_labels:
|
if normalized in seen_theme_labels:
|
||||||
continue
|
continue
|
||||||
seen_theme_labels.add(normalized)
|
seen_theme_labels.add(normalized)
|
||||||
theme_options.append(
|
theme_options.append(
|
||||||
{
|
{
|
||||||
"id": option.get("id") or "",
|
"id": option.get("id") or "",
|
||||||
"name": label,
|
"name": label,
|
||||||
"source": "existing",
|
"source": "existing",
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
# Workbook themes are no longer supported as the template has no theme column
|
# Workbook themes are no longer supported as the template has no theme column
|
||||||
pass
|
pass
|
||||||
|
|
||||||
preview_sheets.append(
|
preview_sheets.append(
|
||||||
{
|
{
|
||||||
"sheet_name": sheet_name,
|
"sheet_name": sheet_name,
|
||||||
"region_name": region_name,
|
"region_name": region_name,
|
||||||
"region_id": region_id,
|
"region_id": region_id,
|
||||||
"missing_region": not bool(region_id),
|
"missing_region": not bool(region_id),
|
||||||
"theme_options": theme_options,
|
"theme_options": theme_options,
|
||||||
"permits": permit_summaries,
|
"permits": permit_summaries,
|
||||||
"duplicate_permits": list(duplicate_permits),
|
"duplicate_permits": list(duplicate_permits),
|
||||||
"new_permits": list(new_permits),
|
"new_permits": list(new_permits),
|
||||||
"permit_count": len(permit_summaries),
|
"permit_count": len(permit_summaries),
|
||||||
"risk_count": sheet_risk_total,
|
"risk_count": sheet_risk_total,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"session_id": session_id,
|
"session_id": session_id,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue