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

Function log_behavior

skills/storage-helper/scripts/db_ops.py:819–840  ·  view source on GitHub ↗

Log user behavior

(
    user_id: str,
    push_id: str,
    paper_id: Optional[int],
    action: str,
    action_type: str,
    category: str = "",
    metadata: Optional[Dict] = None
)

Source from the content-addressed store, hash-verified

817# ============== Behavior Log Operations ==============
818
819def log_behavior(
820 user_id: str,
821 push_id: str,
822 paper_id: Optional[int],
823 action: str,
824 action_type: str,
825 category: str = "",
826 metadata: Optional[Dict] = None
827) -> int:
828 """Log user behavior"""
829 conn = get_connection()
830 cursor = conn.cursor()
831 cursor.execute("""
832 INSERT INTO behavior_logs
833 (user_id, push_id, paper_id, action, action_type, category, metadata)
834 VALUES (?, ?, ?, ?, ?, ?, ?)
835 """, (user_id, push_id, paper_id, action, action_type, category,
836 json.dumps(metadata) if metadata else None))
837 conn.commit()
838 log_id = cursor.lastrowid
839 conn.close()
840 return log_id
841
842
843def _build_created_report_record(row: sqlite3.Row, metadata: Optional[Dict[str, Any]] = None) -> Optional[Dict[str, Any]]:

Calls 4

cursorMethod · 0.80
get_connectionFunction · 0.70
executeMethod · 0.45
closeMethod · 0.45