MCPcopy
hub / github.com/IBM/AssetOpsBench / update_workorder

Function update_workorder

src/servers/wo/workorders.py:418–448  ·  view source on GitHub ↗

Update mutable fields on an existing work order.

(
    db,
    wonum: str,
    site_id: str,
    description: Optional[str] = None,
    priority: Optional[int] = None,
    location: Optional[str] = None,
    asset_num: Optional[str] = None,
    notes: Optional[str] = None,
    failure_code: Optional[str] = None,
)

Source from the content-addressed store, hash-verified

416
417
418async def update_workorder(
419 db,
420 wonum: str,
421 site_id: str,
422 description: Optional[str] = None,
423 priority: Optional[int] = None,
424 location: Optional[str] = None,
425 asset_num: Optional[str] = None,
426 notes: Optional[str] = None,
427 failure_code: Optional[str] = None,
428) -> Dict[str, Any]:
429 """Update mutable fields on an existing work order."""
430 with Timer() as t:
431 doc = await db.get(_doc_id(site_id, wonum))
432 if not doc:
433 return error(f"Work order '{wonum}' not found", "NOT_FOUND")
434 if description is not None:
435 doc["description"] = description[:100]
436 if priority is not None:
437 doc["wopriority"] = priority
438 if location is not None:
439 doc["location"] = location
440 if asset_num is not None:
441 doc["assetnum"] = asset_num
442 if notes is not None:
443 doc["description_longdescription"] = notes
444 if failure_code is not None:
445 doc["failurecode"] = failure_code
446
447 await db.put(doc)
448 return envelope(_public(doc), duration_ms=t_ms(t))
449
450
451async def _change_status(

Callers

nothing calls this directly

Calls 8

TimerClass · 0.90
errorFunction · 0.90
envelopeFunction · 0.90
_doc_idFunction · 0.85
_publicFunction · 0.85
t_msFunction · 0.85
getMethod · 0.45
putMethod · 0.45

Tested by

no test coverage detected