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

Function _interaction_bonus

skills/wiki-store/scripts/wiki_db.py:674–699  ·  view source on GitHub ↗
(user_id: str, node: Dict[str, Any])

Source from the content-addressed store, hash-verified

672
673
674def _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
702def all_user_ids() -> List[str]:

Callers 1

search_nodesFunction · 0.85

Calls 4

getMethod · 0.80
fetchallMethod · 0.45
executeMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected