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:
@ -163,7 +163,8 @@ async def upload_file(file: UploadFile = File(...)):
|
|||||||
"default_set": [
|
"default_set": [
|
||||||
col_name
|
col_name
|
||||||
for col_name in row.get("corrected_columns", [])
|
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`
|
], # Specify which keys are explicitly `default_set`
|
||||||
}
|
}
|
||||||
for row in updated_raw_data
|
for row in updated_raw_data
|
||||||
|
@ -68,14 +68,16 @@ class SampleSpreadsheetImporter:
|
|||||||
Tracks corrections and defaults applied separately.
|
Tracks corrections and defaults applied separately.
|
||||||
"""
|
"""
|
||||||
default_applied = False
|
default_applied = False
|
||||||
|
|
||||||
# If the value is None or empty string
|
# If the value is None or empty string
|
||||||
if value is None or (isinstance(value, str) and value.strip() == ""):
|
if value is None or (isinstance(value, str) and value.strip() == ""):
|
||||||
if column_name == "directory":
|
if column_name == "directory":
|
||||||
logger.warning("Directory value is empty. Assigning default value.")
|
logger.warning("Directory value is empty. Assigning default value.")
|
||||||
default_applied = True
|
default_applied = True
|
||||||
return "{sgPuck}/{sgPosition}", default_applied
|
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
|
return None, default_applied
|
||||||
|
|
||||||
# Clean up the value
|
# Clean up the value
|
||||||
|
Reference in New Issue
Block a user