(user_id: str, node: Dict[str, Any])
| 672 | |
| 673 | |
| 674 | def _interaction_bonus(user_id: str, node: Dict[str, Any]) -> float: |
| 675 | paper_node = node["node_id"] if node.get("node_type") == "paper" else (node.get("metadata") or {}).get("parent_paper_id") |
| 676 | if not paper_node: |
| 677 | return 0.0 |
| 678 | conn = db_ops.get_connection() |
| 679 | rows = conn.execute( |
| 680 | """ |
| 681 | SELECT relation, weight |
| 682 | FROM wiki_edges |
| 683 | WHERE user_id = ? |
| 684 | AND src_id = ? |
| 685 | AND dst_id = ? |
| 686 | AND relation IN ('interested_in', 'read', 'skipped') |
| 687 | """, |
| 688 | (user_id, f"user:{user_id}", paper_node), |
| 689 | ).fetchall() |
| 690 | conn.close() |
| 691 | bonus = 0.0 |
| 692 | for row in rows: |
| 693 | if row["relation"] == "read": |
| 694 | bonus += 0.20 |
| 695 | elif row["relation"] == "interested_in": |
| 696 | bonus += 0.14 |
| 697 | elif row["relation"] == "skipped": |
| 698 | bonus -= 0.16 |
| 699 | return bonus |
| 700 | |
| 701 | |
| 702 | def all_user_ids() -> List[str]: |
no test coverage detected