| 3306 | for node in nodes: |
| 3307 | node_type = str(node.get("node_type") or "node") |
| 3308 | by_type[node_type] = by_type.get(node_type, 0) + 1 |
| 3309 | updated_at = node.get("updated_at") |
| 3310 | if updated_at and (latest is None or str(updated_at) > str(latest)): |
| 3311 | latest = updated_at |
| 3312 | |
| 3313 | visible_ids = {str(node.get("node_id") or "") for node in nodes if node.get("node_id")} |
| 3314 | edge_count = 0 |
| 3315 | citation_count = 0 |
| 3316 | if visible_ids: |
| 3317 | conn = db_ops.get_connection() |
| 3318 | placeholders = ",".join("?" for _ in visible_ids) |
| 3319 | edge_count = int( |
| 3320 | conn.execute( |
| 3321 | f""" |
| 3322 | SELECT COUNT(*) AS count |
| 3323 | FROM wiki_edges |
| 3324 | WHERE user_id = ? |
| 3325 | AND src_id IN ({placeholders}) |
| 3326 | AND dst_id IN ({placeholders}) |
| 3327 | """, |
| 3328 | [user_id, *visible_ids, *visible_ids], |
| 3329 | ).fetchone()["count"] |
| 3330 | or 0 |
| 3331 | ) |