(20260309) Added new 'mode' for formatting the muster roll'.
This commit is contained in:
@@ -187,7 +187,8 @@ async def muster_roll_report_generate(
|
||||
success = False
|
||||
report_data = None
|
||||
|
||||
# Figure out the paths:
|
||||
# Figure out the paths,
|
||||
# and read the records:
|
||||
proj_dir = files.get_parent_directory(
|
||||
files.get_file_directory(include_filename = False),
|
||||
depth = 4
|
||||
@@ -201,6 +202,16 @@ async def muster_roll_report_generate(
|
||||
# Note down the status of success or failure:
|
||||
success = True if report_data else False
|
||||
|
||||
# format the report as required:
|
||||
if success:
|
||||
if inbound_data.mode == "array":
|
||||
pass # ... already an array
|
||||
elif inbound_data.mode == "map":
|
||||
report_data["report"] = {
|
||||
r["UserID"]: {k: v for k,v in r.items if k != "User ID"}
|
||||
for r in report_data["report"]
|
||||
}
|
||||
|
||||
# ┳┓
|
||||
# ┣┫┏┓┏┏┓┏┓┏┓┏┏┓
|
||||
# ┛┗┗ ┛┣┛┗┛┛┗┛┗
|
||||
|
||||
@@ -84,6 +84,11 @@ class CosecMusterRollReportRequestData(BaseModel):
|
||||
frozen = True,
|
||||
)
|
||||
|
||||
mode: Literal["array", "map"] = Field(
|
||||
description = "The format in which the response is desired.",
|
||||
frozen = True,
|
||||
)
|
||||
|
||||
# ┏┓ ┏•
|
||||
# ┃ ┏┓┏┓╋┓┏┓
|
||||
# ┗┛┗┛┛┗┛┗┗┫
|
||||
|
||||
Reference in New Issue
Block a user