(
*,
user_id: str,
src_id: str,
dst_id: str,
relation: str,
weight: float = 1.0,
metadata: Optional[Dict[str, Any]] = None,
)
| 404 | |
| 405 | |
| 406 | def upsert_edge( |
| 407 | *, |
| 408 | user_id: str, |
| 409 | src_id: str, |
| 410 | dst_id: str, |
| 411 | relation: str, |
| 412 | weight: float = 1.0, |
| 413 | metadata: Optional[Dict[str, Any]] = None, |
| 414 | ) -> int: |
| 415 | init_wiki_schema() |
| 416 | conn = db_ops.get_connection() |
| 417 | cursor = conn.cursor() |
| 418 | cursor.execute( |
| 419 | """ |
| 420 | INSERT INTO wiki_edges (user_id, src_id, dst_id, relation, weight, metadata_json) |
| 421 | VALUES (?, ?, ?, ?, ?, ?) |
| 422 | ON CONFLICT(user_id, src_id, dst_id, relation) DO UPDATE SET |
| 423 | weight=excluded.weight, |
| 424 | metadata_json=excluded.metadata_json |
| 425 | """, |
| 426 | (user_id, src_id, dst_id, relation, float(weight), _json_dumps(metadata)), |
| 427 | ) |
| 428 | conn.commit() |
| 429 | edge_id = int(cursor.lastrowid or 0) |
| 430 | conn.close() |
| 431 | return edge_id |
| 432 | |
| 433 | |
| 434 | def upsert_citation( |
nothing calls this directly
no test coverage detected