{
"event": "PreToolUse",
"tool_name": "Read",
"tool_input": {
"file_path": "\/var\/www\/scripts\/pipeline\/db.py",
"offset": 470,
"limit": 40
}
}
{
"tool_response": {
"type": "text",
"file": {
"filePath": "\/var\/www\/scripts\/pipeline\/db.py",
"content": " def add_entity_taxonomy(\n self,\n entity_id: int,\n term_id: int,\n relevance: float = 0.7,\n validated: bool = False,\n ) -> int | None:\n \"\"\"\n Add taxonomy mapping for an entity.\n\n Args:\n entity_id: Entity ID\n term_id: Taxonomy term ID\n relevance: Relevance score (0.0-1.0)\n validated: Whether manually validated\n\n Returns:\n Mapping ID or None if already exists\n \"\"\"\n # Check if mapping already exists\n cursor = self.execute(\n \"SELECT id FROM entity_taxonomy_mapping WHERE entity_id = %s AND taxonomy_term_id = %s\",\n (entity_id, term_id),\n )\n existing = cursor.fetchone()\n cursor.close()\n\n if existing:\n return None\n\n try:\n cursor = self.execute(\n \"\"\"INSERT INTO entity_taxonomy_mapping\n (entity_id, taxonomy_term_id, relevance, validated, created_at)\n VALUES (%s, %s, %s, %s, NOW())\"\"\",\n (entity_id, term_id, relevance, 1 if validated else 0),\n )\n self.commit()\n mapping_id = cursor.lastrowid\n cursor.close()",
"numLines": 40,
"startLine": 470,
"totalLines": 718
}
}
}