MCPcopy Create free account
hub / github.com/OpenRaiser/PaperFlow / create_drift_event

Function create_drift_event

scripts/drift_engine.py:1417–1448  ·  view source on GitHub ↗

创建完整的漂移事件记录

(
    user_id: str,
    date: str,
    drift_event: Dict[str, Any],
    profile_before: Dict[str, Any],
    profile_after: Dict[str, Any],
)

Source from the content-addressed store, hash-verified

1415
1416def create_drift_event(
1417 user_id: str,
1418 date: str,
1419 drift_event: Dict[str, Any],
1420 profile_before: Dict[str, Any],
1421 profile_after: Dict[str, Any],
1422) -> Dict[str, Any]:
1423 """创建完整的漂移事件记录"""
1424 before_state = profile_before.get("drift_state", {}) or {}
1425 after_state = profile_after.get("drift_state", {}) or {}
1426 before_status = before_state.get("status", "stable")
1427 after_status = after_state.get("status", "stable")
1428 raw_transition = f"{before_status} → {after_status}"
1429 display_before_status = to_display_drift_status(before_status)
1430 display_status = to_display_drift_status(after_status)
1431 display_transition = f"{display_before_status} → {display_status}"
1432 display_score = 0.0 if display_status == "stable" else float(after_state.get("score", 0.0) or 0.0)
1433
1434 return {
1435 "timestamp": f"{date}T{datetime.now().strftime('%H:%M:%S')}",
1436 "event_type": drift_event.get("event_type", "drift"),
1437 "user_id": user_id,
1438 "date": date,
1439 "transition": display_transition,
1440 "display_transition": display_transition,
1441 "display_status": display_status,
1442 "display_score": round(display_score, 2),
1443 "internal_transition": raw_transition,
1444 "internal_status": after_status,
1445 "score_delta": after_state.get("score", 0) - before_state.get("score", 0),
1446 **drift_event,
1447 }

Callers 1

simulate_one_dayFunction · 0.90

Calls 3

to_display_drift_statusFunction · 0.85
getMethod · 0.80
nowMethod · 0.80

Tested by

no test coverage detected