{
"event": "PreToolUse",
"tool_name": "Read",
"tool_input": {
"file_path": "\/var\/www\/dev.campus.systemische-tools.de\/src\/Infrastructure\/Persistence\/ChunkRepository.php",
"offset": 215,
"limit": 30
}
}
{
"tool_response": {
"type": "text",
"file": {
"filePath": "\/var\/www\/dev.campus.systemische-tools.de\/src\/Infrastructure\/Persistence\/SemanticSearchRepository.php",
"content": "<?php\n\ndeclare(strict_types=1);\n\nnamespace Infrastructure\\Persistence;\n\n\/\/ @responsibility: Semantik-Suche und Graph-Daten für Semantic Explorer\n\nuse Domain\\Repository\\SemanticSearchRepositoryInterface;\nuse PDO;\n\nfinal class SemanticSearchRepository implements SemanticSearchRepositoryInterface\n{\n private PDO $db;\n\n public function __construct(PDO $pdo)\n {\n $this->db = $pdo;\n }\n\n \/**\n * {@inheritDoc}\n *\/\n public function getSemanticStats(): array\n {\n return $this->db->query(\n 'SELECT\n (SELECT COUNT(*) FROM entities) as entities,\n (SELECT COUNT(*) FROM entity_relations) as relations,\n (SELECT COUNT(*) FROM taxonomy_terms) as taxonomy,\n (SELECT COUNT(*) FROM ontology_classes) as ontology,\n (SELECT COUNT(*) FROM chunk_semantics) as semantics,\n (SELECT COUNT(*) FROM stopwords WHERE is_active = 1) as stopwords,\n (SELECT COUNT(*) FROM entities) as total,\n (SELECT COUNT(DISTINCT type) FROM entities) as types,\n (SELECT COUNT(DISTINCT chunk_id) FROM chunk_entities) as linked_chunks,\n (SELECT COUNT(DISTINCT c.document_id) FROM chunk_entities ce JOIN chunks c ON ce.chunk_id = c.id) as linked_docs'\n )->fetch();\n }\n\n \/**\n * {@inheritDoc}\n *\/\n public function findEntitySemantics(string $search = '', string $type = '', int $limit = 50, int $offset = 0): array\n {\n \/\/ Deduplicated entities with aggregated chunk\/document counts\n $sql = 'SELECT e.id, e.name, e.canonical_name, e.type, e.description, e.status,\n COUNT(DISTINCT ce.chunk_id) as chunk_count,\n COUNT(DISTINCT c.document_id) as document_count,\n MIN(ce.chunk_id) as first_chunk_id,\n MIN(d.filename) as first_filename,\n MIN(d.id) as first_document_id\n FROM entities e\n LEFT JOIN chunk_entities ce ON e.id = ce.entity_id\n LEFT JOIN chunks c ON ce.chunk_id = c.id\n LEFT JOIN documents d ON c.document_id = d.id\n WHERE 1=1';\n\n $params = [];\n\n if ($search !== '') {\n $sql .= ' AND (e.name LIKE :search OR e.description LIKE :search2 OR e.canonical_name LIKE :search3)';\n $params['search'] = '%' . $search . '%';\n $params['search2'] = '%' . $search . '%';\n $params['search3'] = '%' . $search . '%';\n }\n\n if ($type !== '') {\n $sql .= ' AND e.type = :type';\n $params['type'] = $type;\n }\n\n $sql .= ' GROUP BY e.id, e.name, e.canonical_name, e.type, e.description, e.status';\n $sql .= ' ORDER BY e.name LIMIT ' . $limit . ' OFFSET ' . $offset;\n\n $stmt = $this->db->prepare($sql);\n $stmt->execute($params);\n\n return $stmt->fetchAll();\n }",
"numLines": 80,
"startLine": 1,
"totalLines": 256
}
}
}