fix(selos): corrigir geração de selos e adicionar ícones visuais
- Corrigir extração de orientações (tipo "Orientação de Discentes") - Selos de premiação agora usam campo papel (Autor/Orientador/Coorientador) - Adicionar ícones visuais aos selos (emojis Unicode) - Adicionar estilos CSS para novos tipos de selos - Melhorias no Oracle client e ranking repository
This commit is contained in:
@@ -1,8 +1,9 @@
|
||||
import logging
|
||||
from typing import Dict, Any, List
|
||||
from typing import Dict, Any, List, Optional
|
||||
|
||||
from ...infrastructure.elasticsearch.client import ElasticsearchClient
|
||||
from ...infrastructure.ranking_store import RankingEntry, RankingStore
|
||||
from ...infrastructure.oracle.ranking_repository import RankingOracleRepository
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
from ...infrastructure.repositories.consultor_repository_impl import ConsultorRepositoryImpl
|
||||
@@ -14,9 +15,11 @@ class ProcessarRankingJob:
|
||||
self,
|
||||
es_client: ElasticsearchClient,
|
||||
ranking_store: RankingStore,
|
||||
ranking_oracle_repo: Optional[RankingOracleRepository] = None,
|
||||
):
|
||||
self.es_client = es_client
|
||||
self.ranking_store = ranking_store
|
||||
self.ranking_oracle_repo = ranking_oracle_repo
|
||||
self.consultor_repo = ConsultorRepositoryImpl(es_client, oracle_client=None)
|
||||
self._consultores: List[dict] = []
|
||||
|
||||
@@ -40,6 +43,10 @@ class ProcessarRankingJob:
|
||||
entries = self._gerar_entries_ordenadas(self._consultores)
|
||||
await self.ranking_store.set_entries(entries)
|
||||
|
||||
if self.ranking_oracle_repo:
|
||||
job_status.mensagem = "Persistindo no Oracle..."
|
||||
await self._persistir_oracle(self._consultores, limpar_antes)
|
||||
|
||||
estatisticas = self._obter_estatisticas(entries)
|
||||
|
||||
job_status.finalizar(sucesso=True)
|
||||
@@ -253,3 +260,21 @@ class ProcessarRankingJob:
|
||||
"d": float(round(sum(e.bloco_d for e in entries) / total, 2)),
|
||||
},
|
||||
}
|
||||
|
||||
async def _persistir_oracle(self, consultores: List[dict], limpar_antes: bool) -> None:
|
||||
import asyncio
|
||||
if not self.ranking_oracle_repo:
|
||||
return
|
||||
|
||||
def _sync_persist():
|
||||
if limpar_antes:
|
||||
self.ranking_oracle_repo.limpar_tabela()
|
||||
|
||||
batch_size = 500
|
||||
for i in range(0, len(consultores), batch_size):
|
||||
batch = consultores[i:i + batch_size]
|
||||
self.ranking_oracle_repo.inserir_batch(batch)
|
||||
|
||||
self.ranking_oracle_repo.atualizar_posicoes()
|
||||
|
||||
await asyncio.get_event_loop().run_in_executor(None, _sync_persist)
|
||||
|
||||
Reference in New Issue
Block a user