feat(raw-data): adicionar visualização de dados brutos do ATUACAPES
- Novo endpoint GET /api/v1/consultor/{id}/raw para buscar documento completo do ES
- Novo componente RawDataModal com formatação inteligente de campos
- Botão de acesso rápido no ConsultorCard (ícone ⋮)
- Melhorias de estilo no Header e ConsultorCard
This commit is contained in:
@@ -2,7 +2,6 @@ ES_URL=http://localhost:9200
|
||||
ES_INDEX=atuacapes
|
||||
ES_USER=seu_usuario_elastic
|
||||
ES_PASSWORD=sua_senha_elastic
|
||||
ES_PASS=sua_senha_elastic
|
||||
|
||||
ORACLE_USER=seu_usuario_oracle
|
||||
ORACLE_PASSWORD=sua_senha_oracle
|
||||
|
||||
@@ -68,6 +68,33 @@ class ElasticsearchClient:
|
||||
except Exception as e:
|
||||
raise RuntimeError(f"Erro ao buscar consultor {id_pessoa}: {e}")
|
||||
|
||||
async def buscar_documento_completo(self, id_pessoa: int) -> Optional[dict]:
|
||||
try:
|
||||
query = {
|
||||
"query": {"term": {"id": id_pessoa}},
|
||||
"size": 1,
|
||||
}
|
||||
|
||||
response = await self.client.post(
|
||||
f"{self.url}/{self.index}/_search",
|
||||
json=query
|
||||
)
|
||||
response.raise_for_status()
|
||||
|
||||
data = response.json()
|
||||
hits = data.get("hits", {}).get("hits", [])
|
||||
if hits:
|
||||
hit = hits[0]
|
||||
return {
|
||||
"_index": hit.get("_index"),
|
||||
"_id": hit.get("_id"),
|
||||
"_score": hit.get("_score"),
|
||||
"_source": hit.get("_source"),
|
||||
}
|
||||
return None
|
||||
except Exception as e:
|
||||
raise RuntimeError(f"Erro ao buscar documento completo {id_pessoa}: {e}")
|
||||
|
||||
async def buscar_com_atuacoes(self, size: int = 1000, from_: int = 0) -> list:
|
||||
try:
|
||||
query = {
|
||||
|
||||
@@ -48,6 +48,10 @@ def get_oracle_client() -> OracleClient:
|
||||
return oracle_client
|
||||
|
||||
|
||||
def get_es_client() -> ElasticsearchClient:
|
||||
return es_client
|
||||
|
||||
|
||||
def get_ranking_oracle_repo() -> RankingOracleRepository:
|
||||
return ranking_oracle_repo
|
||||
|
||||
|
||||
@@ -21,7 +21,8 @@ from ..schemas.ranking_schema import (
|
||||
ProcessarRankingResponseSchema,
|
||||
ConsultaNomeSchema,
|
||||
)
|
||||
from .dependencies import get_repository, get_ranking_store, get_processar_job
|
||||
from .dependencies import get_repository, get_ranking_store, get_processar_job, get_es_client
|
||||
from ...infrastructure.elasticsearch.client import ElasticsearchClient
|
||||
from ...application.jobs.job_status import job_status
|
||||
|
||||
router = APIRouter(prefix="/api/v1", tags=["ranking"])
|
||||
@@ -305,3 +306,17 @@ async def processar_ranking(
|
||||
mensagem="Processamento do ranking iniciado em background",
|
||||
job_id="ranking_job"
|
||||
)
|
||||
|
||||
|
||||
@router.get("/consultor/{id_pessoa}/raw")
|
||||
async def obter_consultor_raw(
|
||||
id_pessoa: int,
|
||||
es_client: ElasticsearchClient = Depends(get_es_client),
|
||||
):
|
||||
try:
|
||||
documento = await es_client.buscar_documento_completo(id_pessoa)
|
||||
if not documento:
|
||||
raise HTTPException(status_code=404, detail=f"Consultor {id_pessoa} não encontrado no Elasticsearch")
|
||||
return documento
|
||||
except RuntimeError as e:
|
||||
raise HTTPException(status_code=500, detail=str(e))
|
||||
|
||||
Reference in New Issue
Block a user