From edb4e00880432d15c3c3a7a8c1fc474187a93351 Mon Sep 17 00:00:00 2001 From: Frederico Castro Date: Sat, 27 Dec 2025 19:55:25 -0300 Subject: [PATCH] fix(api): corrigir conversao do campo ano em titulacoes Campo ano vinha como string do Elasticsearch causando TypeError ao ordenar titulacoes com operador unario negativo. Corrigido nos endpoints: - /ranking/paginado - /consultor/{id}/lattes --- backend/src/interface/api/routes.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/backend/src/interface/api/routes.py b/backend/src/interface/api/routes.py index 4f4488c..cab1546 100644 --- a/backend/src/interface/api/routes.py +++ b/backend/src/interface/api/routes.py @@ -291,10 +291,12 @@ async def ranking_paginado( ies_obj = t.get("ies", {}) area_obj = t.get("areaConhecimento", {}) programa_obj = t.get("programa", {}) + ano_raw = t.get("ano") + ano_int = int(ano_raw) if ano_raw and str(ano_raw).isdigit() else None titulacoes_formatadas.append({ "grau": grau_obj.get("nome", ""), "hierarquia": grau_obj.get("hierarquia"), - "ano": t.get("ano"), + "ano": ano_int, "inicio": t.get("inicio"), "fim": t.get("fim"), "ies_nome": ies_obj.get("nome"), @@ -523,10 +525,12 @@ async def obter_lattes( ies_obj = t.get("ies", {}) area_obj = t.get("areaConhecimento", {}) programa_obj = t.get("programa", {}) + ano_raw = t.get("ano") + ano_int = int(ano_raw) if ano_raw and str(ano_raw).isdigit() else None titulacoes.append({ "grau": grau_obj.get("nome", ""), "hierarquia": grau_obj.get("hierarquia"), - "ano": t.get("ano"), + "ano": ano_int, "inicio": t.get("inicio"), "fim": t.get("fim"), "ies_nome": ies_obj.get("nome"),