feat: harden against empty jira
This commit is contained in:
parent
24f2e7718b
commit
2f0f87ea8c
1 changed files with 22 additions and 1 deletions
|
|
@ -509,7 +509,28 @@ class TicketSharepointSyncInterface:
|
|||
def _create_csv_content(self, data: list[dict]) -> bytes:
|
||||
"""Create CSV content with 4-row structure matching reference code."""
|
||||
if not data:
|
||||
return b""
|
||||
# Build an empty table with the expected columns from schema
|
||||
cols = list(self.task_sync_definition.keys())
|
||||
|
||||
df = pd.DataFrame(columns=cols)
|
||||
|
||||
# Row 1 & 2: keep your current banner lines
|
||||
header_row1 = pd.DataFrame(
|
||||
[["Header 1"] + [""] * (len(cols) - 1)], columns=cols
|
||||
)
|
||||
header_row2 = pd.DataFrame(
|
||||
[["Header 2"] + [""] * (len(cols) - 1)], columns=cols
|
||||
)
|
||||
|
||||
# Row 3: table headers
|
||||
table_headers = pd.DataFrame([cols], columns=cols)
|
||||
|
||||
final_df = pd.concat(
|
||||
[header_row1, header_row2, table_headers, df], ignore_index=True
|
||||
)
|
||||
csv_text = StringIO()
|
||||
final_df.to_csv(csv_text, index=False, header=False)
|
||||
return csv_text.getvalue().encode("utf-8")
|
||||
|
||||
# Create DataFrame from data
|
||||
df = pd.DataFrame(data)
|
||||
|
|
|
|||
Loading…
Reference in a new issue