Set default values for empty "priority" column in spreadsheets.

Added logic to assign a default value of 1 to empty "priority" fields in the spreadsheet service. Adjusted the router to correctly track columns explicitly marked as defaulted.
This commit is contained in:
GotthardG
2025-01-14 22:18:14 +01:00
parent c0951292d0
commit 7861082a02
2 changed files with 6 additions and 3 deletions

View File

@ -163,7 +163,8 @@ async def upload_file(file: UploadFile = File(...)):
"default_set": [
col_name
for col_name in row.get("corrected_columns", [])
if row.get("default_set", False) and col_name == "directory"
if row.get("default_set", False)
and col_name in row.get("defaulted_columns", [])
], # Specify which keys are explicitly `default_set`
}
for row in updated_raw_data

View File

@ -68,14 +68,16 @@ class SampleSpreadsheetImporter:
Tracks corrections and defaults applied separately.
"""
default_applied = False
# If the value is None or empty string
if value is None or (isinstance(value, str) and value.strip() == ""):
if column_name == "directory":
logger.warning("Directory value is empty. Assigning default value.")
default_applied = True
return "{sgPuck}/{sgPosition}", default_applied
elif column_name == "priority":
logger.warning("Priority value is empty. Assigning default value.")
default_applied = True
return 1, default_applied
return None, default_applied
# Clean up the value