feat: Sistema de Ranking de Consultores CAPES - versão inicial
Backend (FastAPI + DDD):
- Arquitetura DDD com camadas Domain, Application, Infrastructure, Interface
- Integração com Elasticsearch (ATUACAPES) para dados de consultores
- Integração com Oracle (SUCUPIRA_PAINEL) para coordenações PPG
- Cálculo dos 4 componentes de pontuação (A, B, C, D)
- Cache em memória para otimização de performance
- API REST com endpoints /ranking, /ranking/detalhado, /consultor/{id}
Frontend (React + Vite):
- Interface responsiva com cards expansíveis
- Visualização detalhada de pontuação por componente
- Filtro por quantidade de consultores (Top 10, 50, 100, etc)
Docker:
- docker-compose com shared_network externa
- Backend com Oracle Instant Client
- Frontend com Vite dev server
This commit is contained in:
8
.env.example
Normal file
8
.env.example
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
ES_URL=http://seu-elasticsearch:9200
|
||||||
|
ES_INDEX=atuacapes
|
||||||
|
ES_USER=seu_usuario_elastic
|
||||||
|
ES_PASSWORD=sua_senha_elastic
|
||||||
|
|
||||||
|
ORACLE_USER=FREDERICOAC
|
||||||
|
ORACLE_PASSWORD=FREDEricoac
|
||||||
|
ORACLE_DSN=oracledhtsrv02.hom.capes.gov.br:1521/hom_dr
|
||||||
30
.gitignore
vendored
Normal file
30
.gitignore
vendored
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
.env
|
||||||
|
__pycache__/
|
||||||
|
*.py[cod]
|
||||||
|
*$py.class
|
||||||
|
*.so
|
||||||
|
.Python
|
||||||
|
env/
|
||||||
|
venv/
|
||||||
|
ENV/
|
||||||
|
build/
|
||||||
|
develop-eggs/
|
||||||
|
dist/
|
||||||
|
downloads/
|
||||||
|
eggs/
|
||||||
|
.eggs/
|
||||||
|
lib/
|
||||||
|
lib64/
|
||||||
|
parts/
|
||||||
|
sdist/
|
||||||
|
var/
|
||||||
|
wheels/
|
||||||
|
*.egg-info/
|
||||||
|
.installed.cfg
|
||||||
|
*.egg
|
||||||
|
node_modules/
|
||||||
|
.DS_Store
|
||||||
|
.vscode/
|
||||||
|
.idea/
|
||||||
|
*.log
|
||||||
|
.cache/
|
||||||
267
README.md
Normal file
267
README.md
Normal file
@@ -0,0 +1,267 @@
|
|||||||
|
# Sistema de Ranking de Consultores CAPES
|
||||||
|
|
||||||
|
Sistema completo de ranking de consultores CAPES baseado na Minuta Técnica, desenvolvido com arquitetura DDD (Domain-Driven Design).
|
||||||
|
|
||||||
|
## Arquitetura
|
||||||
|
|
||||||
|
### Backend (Python + FastAPI + DDD)
|
||||||
|
- **Domain Layer**: Entities, Value Objects, Domain Services
|
||||||
|
- **Application Layer**: Use Cases, DTOs
|
||||||
|
- **Infrastructure Layer**: Repositories, Elasticsearch Client, Oracle Client
|
||||||
|
- **Interface Layer**: FastAPI Routes, Schemas, Dependencies
|
||||||
|
|
||||||
|
### Frontend (React + Vite)
|
||||||
|
- Interface moderna baseada no layout do HTML de referência
|
||||||
|
- Componentes reutilizáveis
|
||||||
|
- Integração com API via Axios
|
||||||
|
- Design responsivo
|
||||||
|
|
||||||
|
## Estrutura do Projeto
|
||||||
|
|
||||||
|
```
|
||||||
|
ranking/
|
||||||
|
├── backend/
|
||||||
|
│ ├── src/
|
||||||
|
│ │ ├── domain/
|
||||||
|
│ │ │ ├── entities/
|
||||||
|
│ │ │ │ └── consultor.py
|
||||||
|
│ │ │ ├── value_objects/
|
||||||
|
│ │ │ │ ├── periodo.py
|
||||||
|
│ │ │ │ └── pontuacao.py
|
||||||
|
│ │ │ ├── repositories/
|
||||||
|
│ │ │ │ └── consultor_repository.py
|
||||||
|
│ │ │ └── services/
|
||||||
|
│ │ │ └── calculador_pontuacao.py
|
||||||
|
│ │ ├── application/
|
||||||
|
│ │ │ ├── dtos/
|
||||||
|
│ │ │ │ └── consultor_dto.py
|
||||||
|
│ │ │ └── use_cases/
|
||||||
|
│ │ │ ├── obter_ranking.py
|
||||||
|
│ │ │ └── obter_consultor.py
|
||||||
|
│ │ ├── infrastructure/
|
||||||
|
│ │ │ ├── elasticsearch/
|
||||||
|
│ │ │ │ └── client.py
|
||||||
|
│ │ │ ├── oracle/
|
||||||
|
│ │ │ │ └── client.py
|
||||||
|
│ │ │ └── repositories/
|
||||||
|
│ │ │ └── consultor_repository_impl.py
|
||||||
|
│ │ └── interface/
|
||||||
|
│ │ ├── api/
|
||||||
|
│ │ │ ├── app.py
|
||||||
|
│ │ │ ├── routes.py
|
||||||
|
│ │ │ ├── config.py
|
||||||
|
│ │ │ └── dependencies.py
|
||||||
|
│ │ └── schemas/
|
||||||
|
│ │ └── consultor_schema.py
|
||||||
|
│ ├── pyproject.toml
|
||||||
|
│ ├── Dockerfile
|
||||||
|
│ └── .env.example
|
||||||
|
│
|
||||||
|
├── frontend/
|
||||||
|
│ ├── src/
|
||||||
|
│ │ ├── components/
|
||||||
|
│ │ │ ├── Header.jsx
|
||||||
|
│ │ │ ├── Header.css
|
||||||
|
│ │ │ ├── ConsultorCard.jsx
|
||||||
|
│ │ │ └── ConsultorCard.css
|
||||||
|
│ │ ├── services/
|
||||||
|
│ │ │ └── api.js
|
||||||
|
│ │ ├── App.jsx
|
||||||
|
│ │ ├── App.css
|
||||||
|
│ │ ├── main.jsx
|
||||||
|
│ │ └── index.css
|
||||||
|
│ ├── package.json
|
||||||
|
│ ├── vite.config.js
|
||||||
|
│ ├── Dockerfile
|
||||||
|
│ └── nginx.conf
|
||||||
|
│
|
||||||
|
├── docker-compose.yml
|
||||||
|
├── .env.example
|
||||||
|
├── .gitignore
|
||||||
|
└── README.md
|
||||||
|
```
|
||||||
|
|
||||||
|
## Componentes de Pontuação
|
||||||
|
|
||||||
|
### Componente A: Coordenação CAPES (máx 450 pts)
|
||||||
|
- **CA**: 200 base + 100 tempo + 100 áreas + 20 retorno + 30 bônus = 450
|
||||||
|
- **CAJ**: 150 base + 80 tempo + 100 áreas + 20 retorno + 20 bônus = 370
|
||||||
|
- **CAJ-MP**: 120 base + 60 tempo + 100 áreas + 20 retorno + 15 bônus = 315
|
||||||
|
- **CAM**: 100 base + 50 tempo + 100 áreas + 20 retorno + 10 bônus = 280
|
||||||
|
|
||||||
|
### Componente B: Coordenação de Programa PPG (máx 180 pts)
|
||||||
|
- Base: 70 pts
|
||||||
|
- Tempo: 5 pts/ano (máx 50 pts)
|
||||||
|
- Programas extras: 20 pts/programa (máx 40 pts)
|
||||||
|
- Bônus ativo: 20 pts
|
||||||
|
|
||||||
|
### Componente C: Consultoria (máx 230 pts)
|
||||||
|
- Ativo: 150 pts | Histórico: 100 pts
|
||||||
|
- Tempo: 5 pts/ano (máx 50 pts)
|
||||||
|
- Eventos: 2 pts/evento (máx 20 pts)
|
||||||
|
- Responsável: 5 pts/vez (máx 25 pts)
|
||||||
|
- Áreas extras: 10 pts/área (máx 30 pts)
|
||||||
|
|
||||||
|
### Componente D: Premiações (máx 180 pts)
|
||||||
|
- Premiação: 60 pts
|
||||||
|
- Avaliação: 40 pts
|
||||||
|
- Inscrição: 20 pts
|
||||||
|
|
||||||
|
## Requisitos
|
||||||
|
|
||||||
|
- Python 3.11+
|
||||||
|
- Node.js 18+
|
||||||
|
- Docker e Docker Compose (opcional)
|
||||||
|
- Acesso ao Elasticsearch (ATUACAPES)
|
||||||
|
- Acesso ao Oracle (SUCUPIRA_PAINEL)
|
||||||
|
|
||||||
|
## Setup Local
|
||||||
|
|
||||||
|
### Backend
|
||||||
|
|
||||||
|
1. Entre no diretório do backend:
|
||||||
|
```bash
|
||||||
|
cd backend
|
||||||
|
```
|
||||||
|
|
||||||
|
2. Crie ambiente virtual e instale dependências:
|
||||||
|
```bash
|
||||||
|
poetry install
|
||||||
|
```
|
||||||
|
|
||||||
|
3. Configure as variáveis de ambiente:
|
||||||
|
```bash
|
||||||
|
cp .env.example .env
|
||||||
|
```
|
||||||
|
|
||||||
|
4. Edite `.env` com suas credenciais:
|
||||||
|
```
|
||||||
|
ES_URL=http://seu-elasticsearch:9200
|
||||||
|
ES_INDEX=atuacapes
|
||||||
|
ES_USER=seu_usuario_elastic
|
||||||
|
ES_PASSWORD=sua_senha_elastic
|
||||||
|
ORACLE_USER=seu_usuario
|
||||||
|
ORACLE_PASSWORD=sua_senha
|
||||||
|
ORACLE_DSN=host:1521/service_name
|
||||||
|
```
|
||||||
|
|
||||||
|
5. Execute o backend:
|
||||||
|
```bash
|
||||||
|
poetry run python src/main.py
|
||||||
|
```
|
||||||
|
|
||||||
|
A API estará disponível em `http://localhost:8000`
|
||||||
|
|
||||||
|
### Frontend
|
||||||
|
|
||||||
|
1. Entre no diretório do frontend:
|
||||||
|
```bash
|
||||||
|
cd frontend
|
||||||
|
```
|
||||||
|
|
||||||
|
2. Instale dependências:
|
||||||
|
```bash
|
||||||
|
npm install
|
||||||
|
```
|
||||||
|
|
||||||
|
3. Execute em modo desenvolvimento:
|
||||||
|
```bash
|
||||||
|
npm run dev
|
||||||
|
```
|
||||||
|
|
||||||
|
O frontend estará disponível em `http://localhost:5173`
|
||||||
|
|
||||||
|
## Setup com Docker
|
||||||
|
|
||||||
|
1. Configure as variáveis de ambiente:
|
||||||
|
```bash
|
||||||
|
cp .env.example .env
|
||||||
|
```
|
||||||
|
|
||||||
|
2. Edite `.env` com suas credenciais
|
||||||
|
|
||||||
|
3. Execute com Docker Compose:
|
||||||
|
```bash
|
||||||
|
docker-compose up -d
|
||||||
|
```
|
||||||
|
|
||||||
|
- Backend: `http://localhost:8000`
|
||||||
|
- Frontend: `http://localhost`
|
||||||
|
|
||||||
|
## Endpoints da API
|
||||||
|
|
||||||
|
### GET /api/v1/ranking
|
||||||
|
Retorna o ranking resumido de consultores.
|
||||||
|
|
||||||
|
**Query Parameters:**
|
||||||
|
- `limite` (int, default=100): Limite de consultores
|
||||||
|
- `offset` (int, default=0): Offset para paginação
|
||||||
|
- `componente` (str, optional): Filtrar por componente (a, b, c, d)
|
||||||
|
|
||||||
|
### GET /api/v1/ranking/detalhado
|
||||||
|
Retorna o ranking completo com todos os detalhes.
|
||||||
|
|
||||||
|
**Query Parameters:**
|
||||||
|
- `limite` (int, default=100): Limite de consultores
|
||||||
|
- `componente` (str, optional): Filtrar por componente (a, b, c, d)
|
||||||
|
|
||||||
|
### GET /api/v1/consultor/{id_pessoa}
|
||||||
|
Retorna detalhes completos de um consultor específico.
|
||||||
|
|
||||||
|
### GET /api/v1/health
|
||||||
|
Health check da API.
|
||||||
|
|
||||||
|
## Fontes de Dados
|
||||||
|
|
||||||
|
### Elasticsearch (ATUACAPES)
|
||||||
|
- Índice: `atuacapes__1763197236`
|
||||||
|
- Campos: `id`, `dadosPessoais`, `atuacoes`
|
||||||
|
- Tipos de atuação:
|
||||||
|
- Coordenação de Área de Avaliação
|
||||||
|
- Consultor
|
||||||
|
- Premiação Prêmio
|
||||||
|
- Avaliação Prêmio
|
||||||
|
- Inscrição Prêmio
|
||||||
|
|
||||||
|
### Oracle (SUCUPIRA_PAINEL)
|
||||||
|
- Tabela: `VM_COORDENADOR`
|
||||||
|
- JOIN com: `VM_PROGRAMA_SUCUPIRA`, `VM_AREA_CONHECIMENTO`, `VM_AREA_AVALIACAO`
|
||||||
|
- 29.546 registros (4.150 ativos, 25.396 históricos)
|
||||||
|
|
||||||
|
## Documentação da API
|
||||||
|
|
||||||
|
Após iniciar o backend, acesse:
|
||||||
|
- Swagger UI: `http://localhost:8000/docs`
|
||||||
|
- ReDoc: `http://localhost:8000/redoc`
|
||||||
|
|
||||||
|
## Desenvolvimento
|
||||||
|
|
||||||
|
### Testes
|
||||||
|
```bash
|
||||||
|
cd backend
|
||||||
|
poetry run pytest
|
||||||
|
```
|
||||||
|
|
||||||
|
### Linting
|
||||||
|
```bash
|
||||||
|
poetry run black src/
|
||||||
|
poetry run ruff check src/
|
||||||
|
```
|
||||||
|
|
||||||
|
### Build para Produção
|
||||||
|
|
||||||
|
**Backend:**
|
||||||
|
```bash
|
||||||
|
docker build -t ranking-capes-backend ./backend
|
||||||
|
```
|
||||||
|
|
||||||
|
**Frontend:**
|
||||||
|
```bash
|
||||||
|
cd frontend
|
||||||
|
npm run build
|
||||||
|
```
|
||||||
|
|
||||||
|
## Referências
|
||||||
|
|
||||||
|
- Documentação dos critérios: `.claude/rules/ranking-consultores-capes.md`
|
||||||
|
- Queries e mapeamentos: `.claude/rules/ranking-queries-elasticsearch.md`
|
||||||
16
backend/.env.example
Normal file
16
backend/.env.example
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
ES_URL=http://localhost:9200
|
||||||
|
ES_INDEX=atuacapes__1763197236
|
||||||
|
ES_USER=seu_usuario_elastic
|
||||||
|
ES_PASSWORD=sua_senha_elastic
|
||||||
|
ES_DEFAULT_SOURCE_FIELDS=id,dadosPessoais.nome,dadosPessoais.cpf,atuacoes
|
||||||
|
|
||||||
|
ORACLE_USER=seu_usuario
|
||||||
|
ORACLE_PASSWORD=sua_senha
|
||||||
|
ORACLE_DSN=host:1521/service_name
|
||||||
|
|
||||||
|
API_HOST=0.0.0.0
|
||||||
|
API_PORT=8000
|
||||||
|
API_RELOAD=true
|
||||||
|
CORS_ORIGINS=http://localhost:3000,http://localhost:5173
|
||||||
|
|
||||||
|
LOG_LEVEL=INFO
|
||||||
31
backend/Dockerfile
Normal file
31
backend/Dockerfile
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
FROM python:3.11-slim
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
RUN apt-get update && apt-get install -y \
|
||||||
|
gcc \
|
||||||
|
wget \
|
||||||
|
unzip \
|
||||||
|
&& (apt-get install -y libaio1t64 || apt-get install -y libaio1 || true) \
|
||||||
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
|
RUN wget https://download.oracle.com/otn_software/linux/instantclient/2115000/instantclient-basic-linux.x64-21.15.0.0.0dbru.zip \
|
||||||
|
&& unzip instantclient-basic-linux.x64-21.15.0.0.0dbru.zip -d /opt/oracle \
|
||||||
|
&& rm instantclient-basic-linux.x64-21.15.0.0.0dbru.zip \
|
||||||
|
&& sh -c "echo /opt/oracle/instantclient_21_15 > /etc/ld.so.conf.d/oracle-instantclient.conf" \
|
||||||
|
&& ln -sf /usr/lib/x86_64-linux-gnu/libaio.so.1t64 /usr/lib/x86_64-linux-gnu/libaio.so.1 || true \
|
||||||
|
&& ldconfig
|
||||||
|
|
||||||
|
ENV LD_LIBRARY_PATH=/opt/oracle/instantclient_21_15:$LD_LIBRARY_PATH
|
||||||
|
ENV PATH=/opt/oracle/instantclient_21_15:$PATH
|
||||||
|
|
||||||
|
RUN pip install --upgrade pip
|
||||||
|
|
||||||
|
COPY requirements.txt ./
|
||||||
|
RUN pip install -r requirements.txt
|
||||||
|
|
||||||
|
COPY ./src ./src
|
||||||
|
|
||||||
|
EXPOSE 8000
|
||||||
|
|
||||||
|
CMD ["python", "-m", "uvicorn", "src.interface.api.app:app", "--host", "0.0.0.0", "--port", "8000", "--reload"]
|
||||||
6
backend/poetry.lock
generated
Normal file
6
backend/poetry.lock
generated
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
# This file is automatically generated by poetry
|
||||||
|
# Run `poetry lock` to regenerate it
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "fastapi"
|
||||||
|
version = "0.109.0"
|
||||||
45
backend/pyproject.toml
Normal file
45
backend/pyproject.toml
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
[tool.poetry]
|
||||||
|
name = "ranking-capes"
|
||||||
|
version = "0.1.0"
|
||||||
|
description = "Sistema de Ranking de Consultores CAPES - DDD Architecture"
|
||||||
|
authors = ["CAPES"]
|
||||||
|
readme = "README.md"
|
||||||
|
|
||||||
|
[tool.poetry.dependencies]
|
||||||
|
python = "^3.11"
|
||||||
|
fastapi = "^0.109.0"
|
||||||
|
uvicorn = {extras = ["standard"], version = "^0.27.0"}
|
||||||
|
pydantic = "^2.5.3"
|
||||||
|
pydantic-settings = "^2.1.0"
|
||||||
|
elasticsearch = "^8.11.1"
|
||||||
|
cx-Oracle = "^8.3.0"
|
||||||
|
python-dateutil = "^2.8.2"
|
||||||
|
httpx = "^0.26.0"
|
||||||
|
python-dotenv = "^1.0.0"
|
||||||
|
rich = "^13.7.0"
|
||||||
|
|
||||||
|
[tool.poetry.group.dev.dependencies]
|
||||||
|
pytest = "^7.4.4"
|
||||||
|
pytest-asyncio = "^0.23.3"
|
||||||
|
pytest-cov = "^4.1.0"
|
||||||
|
black = "^24.1.1"
|
||||||
|
ruff = "^0.1.14"
|
||||||
|
mypy = "^1.8.0"
|
||||||
|
|
||||||
|
[build-system]
|
||||||
|
requires = ["poetry-core"]
|
||||||
|
build-backend = "poetry.core.masonry.api"
|
||||||
|
|
||||||
|
[tool.black]
|
||||||
|
line-length = 100
|
||||||
|
target-version = ["py311"]
|
||||||
|
|
||||||
|
[tool.ruff]
|
||||||
|
line-length = 100
|
||||||
|
target-version = "py311"
|
||||||
|
|
||||||
|
[tool.mypy]
|
||||||
|
python_version = "3.11"
|
||||||
|
strict = true
|
||||||
|
warn_return_any = true
|
||||||
|
warn_unused_configs = true
|
||||||
9
backend/requirements.txt
Normal file
9
backend/requirements.txt
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
fastapi==0.109.0
|
||||||
|
uvicorn[standard]==0.27.0
|
||||||
|
pydantic==2.5.3
|
||||||
|
pydantic-settings==2.1.0
|
||||||
|
cx-Oracle==8.3.0
|
||||||
|
python-dateutil==2.8.2
|
||||||
|
httpx==0.26.0
|
||||||
|
python-dotenv==1.0.0
|
||||||
|
aiohttp==3.9.1
|
||||||
0
backend/src/__init__.py
Normal file
0
backend/src/__init__.py
Normal file
0
backend/src/application/__init__.py
Normal file
0
backend/src/application/__init__.py
Normal file
0
backend/src/application/dtos/__init__.py
Normal file
0
backend/src/application/dtos/__init__.py
Normal file
98
backend/src/application/dtos/consultor_dto.py
Normal file
98
backend/src/application/dtos/consultor_dto.py
Normal file
@@ -0,0 +1,98 @@
|
|||||||
|
from dataclasses import dataclass, asdict
|
||||||
|
from typing import List, Optional, Dict, Any
|
||||||
|
from datetime import datetime
|
||||||
|
|
||||||
|
|
||||||
|
@dataclass
|
||||||
|
class PeriodoDTO:
|
||||||
|
inicio: str
|
||||||
|
fim: Optional[str]
|
||||||
|
ativo: bool
|
||||||
|
anos_decorridos: float
|
||||||
|
|
||||||
|
|
||||||
|
@dataclass
|
||||||
|
class CoordenacaoCapesDTO:
|
||||||
|
tipo: str
|
||||||
|
area_avaliacao: str
|
||||||
|
periodo: PeriodoDTO
|
||||||
|
areas_adicionais: List[str]
|
||||||
|
ja_coordenou_antes: bool
|
||||||
|
|
||||||
|
|
||||||
|
@dataclass
|
||||||
|
class CoordenacaoProgramaDTO:
|
||||||
|
id_programa: int
|
||||||
|
nome_programa: str
|
||||||
|
codigo_programa: str
|
||||||
|
nota_ppg: str
|
||||||
|
modalidade: str
|
||||||
|
area_avaliacao: str
|
||||||
|
periodo: PeriodoDTO
|
||||||
|
|
||||||
|
|
||||||
|
@dataclass
|
||||||
|
class ConsultoriaDTO:
|
||||||
|
total_eventos: int
|
||||||
|
eventos_recentes: int
|
||||||
|
primeiro_evento: str
|
||||||
|
ultimo_evento: str
|
||||||
|
vezes_responsavel: int
|
||||||
|
areas: List[str]
|
||||||
|
|
||||||
|
|
||||||
|
@dataclass
|
||||||
|
class PremiacaoDTO:
|
||||||
|
tipo: str
|
||||||
|
nome_premio: str
|
||||||
|
ano: int
|
||||||
|
pontos: int
|
||||||
|
|
||||||
|
|
||||||
|
@dataclass
|
||||||
|
class ComponentePontuacaoDTO:
|
||||||
|
base: int
|
||||||
|
tempo: int
|
||||||
|
extras: int
|
||||||
|
bonus: int
|
||||||
|
retorno: int
|
||||||
|
total: int
|
||||||
|
|
||||||
|
|
||||||
|
@dataclass
|
||||||
|
class PontuacaoCompletaDTO:
|
||||||
|
componente_a: ComponentePontuacaoDTO
|
||||||
|
componente_b: ComponentePontuacaoDTO
|
||||||
|
componente_c: ComponentePontuacaoDTO
|
||||||
|
componente_d: ComponentePontuacaoDTO
|
||||||
|
pontuacao_total: int
|
||||||
|
|
||||||
|
|
||||||
|
@dataclass
|
||||||
|
class ConsultorResumoDTO:
|
||||||
|
id_pessoa: int
|
||||||
|
nome: str
|
||||||
|
anos_atuacao: float
|
||||||
|
ativo: bool
|
||||||
|
veterano: bool
|
||||||
|
pontuacao_total: int
|
||||||
|
rank: Optional[int] = None
|
||||||
|
|
||||||
|
|
||||||
|
@dataclass
|
||||||
|
class ConsultorDetalhadoDTO:
|
||||||
|
id_pessoa: int
|
||||||
|
nome: str
|
||||||
|
cpf: Optional[str]
|
||||||
|
anos_atuacao: float
|
||||||
|
ativo: bool
|
||||||
|
veterano: bool
|
||||||
|
coordenacoes_capes: List[CoordenacaoCapesDTO]
|
||||||
|
coordenacoes_programas: List[CoordenacaoProgramaDTO]
|
||||||
|
consultoria: Optional[ConsultoriaDTO]
|
||||||
|
premiacoes: List[PremiacaoDTO]
|
||||||
|
pontuacao: PontuacaoCompletaDTO
|
||||||
|
rank: Optional[int] = None
|
||||||
|
|
||||||
|
def to_dict(self) -> Dict[str, Any]:
|
||||||
|
return asdict(self)
|
||||||
0
backend/src/application/use_cases/__init__.py
Normal file
0
backend/src/application/use_cases/__init__.py
Normal file
23
backend/src/application/use_cases/obter_consultor.py
Normal file
23
backend/src/application/use_cases/obter_consultor.py
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
from typing import Optional
|
||||||
|
|
||||||
|
from ...domain.repositories.consultor_repository import ConsultorRepository
|
||||||
|
from ..dtos.consultor_dto import ConsultorDetalhadoDTO
|
||||||
|
from .obter_ranking import ObterRankingUseCase
|
||||||
|
|
||||||
|
|
||||||
|
class ObterConsultorUseCase:
|
||||||
|
def __init__(self, repository: ConsultorRepository):
|
||||||
|
self.repository = repository
|
||||||
|
self.ranking_use_case = ObterRankingUseCase(repository)
|
||||||
|
|
||||||
|
async def executar(self, id_pessoa: int) -> Optional[ConsultorDetalhadoDTO]:
|
||||||
|
consultor = await self.repository.buscar_por_id(id_pessoa)
|
||||||
|
if not consultor:
|
||||||
|
return None
|
||||||
|
|
||||||
|
ranking_completo = await self.repository.buscar_ranking(limite=1000)
|
||||||
|
rank = next(
|
||||||
|
(idx + 1 for idx, c in enumerate(ranking_completo) if c.id_pessoa == id_pessoa), None
|
||||||
|
)
|
||||||
|
|
||||||
|
return self.ranking_use_case._converter_para_dto_detalhado(consultor, rank or 0)
|
||||||
145
backend/src/application/use_cases/obter_ranking.py
Normal file
145
backend/src/application/use_cases/obter_ranking.py
Normal file
@@ -0,0 +1,145 @@
|
|||||||
|
from typing import List, Optional
|
||||||
|
from datetime import datetime
|
||||||
|
|
||||||
|
from ...domain.repositories.consultor_repository import ConsultorRepository
|
||||||
|
from ...domain.entities.consultor import Consultor
|
||||||
|
from ..dtos.consultor_dto import (
|
||||||
|
ConsultorResumoDTO,
|
||||||
|
ConsultorDetalhadoDTO,
|
||||||
|
PeriodoDTO,
|
||||||
|
CoordenacaoCapesDTO,
|
||||||
|
CoordenacaoProgramaDTO,
|
||||||
|
ConsultoriaDTO,
|
||||||
|
PremiacaoDTO,
|
||||||
|
ComponentePontuacaoDTO,
|
||||||
|
PontuacaoCompletaDTO,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
class ObterRankingUseCase:
|
||||||
|
def __init__(self, repository: ConsultorRepository):
|
||||||
|
self.repository = repository
|
||||||
|
|
||||||
|
async def executar(
|
||||||
|
self, limite: int = 100, componente: Optional[str] = None
|
||||||
|
) -> List[ConsultorResumoDTO]:
|
||||||
|
consultores = await self.repository.buscar_ranking(limite=limite, componente=componente)
|
||||||
|
|
||||||
|
return [
|
||||||
|
ConsultorResumoDTO(
|
||||||
|
id_pessoa=c.id_pessoa,
|
||||||
|
nome=c.nome,
|
||||||
|
anos_atuacao=c.anos_atuacao,
|
||||||
|
ativo=c.ativo,
|
||||||
|
veterano=c.veterano,
|
||||||
|
pontuacao_total=c.pontuacao_total,
|
||||||
|
rank=idx + 1,
|
||||||
|
)
|
||||||
|
for idx, c in enumerate(consultores)
|
||||||
|
]
|
||||||
|
|
||||||
|
async def executar_detalhado(
|
||||||
|
self, limite: int = 100, componente: Optional[str] = None
|
||||||
|
) -> List[ConsultorDetalhadoDTO]:
|
||||||
|
consultores = await self.repository.buscar_ranking(limite=limite, componente=componente)
|
||||||
|
|
||||||
|
return [self._converter_para_dto_detalhado(c, idx + 1) for idx, c in enumerate(consultores)]
|
||||||
|
|
||||||
|
def _converter_para_dto_detalhado(
|
||||||
|
self, consultor: Consultor, rank: int
|
||||||
|
) -> ConsultorDetalhadoDTO:
|
||||||
|
return ConsultorDetalhadoDTO(
|
||||||
|
id_pessoa=consultor.id_pessoa,
|
||||||
|
nome=consultor.nome,
|
||||||
|
cpf=consultor.cpf,
|
||||||
|
anos_atuacao=consultor.anos_atuacao,
|
||||||
|
ativo=consultor.ativo,
|
||||||
|
veterano=consultor.veterano,
|
||||||
|
coordenacoes_capes=[
|
||||||
|
CoordenacaoCapesDTO(
|
||||||
|
tipo=cc.tipo,
|
||||||
|
area_avaliacao=cc.area_avaliacao,
|
||||||
|
periodo=PeriodoDTO(
|
||||||
|
inicio=cc.periodo.inicio.isoformat(),
|
||||||
|
fim=cc.periodo.fim.isoformat() if cc.periodo.fim else None,
|
||||||
|
ativo=cc.periodo.ativo,
|
||||||
|
anos_decorridos=cc.periodo.anos_decorridos,
|
||||||
|
),
|
||||||
|
areas_adicionais=cc.areas_adicionais,
|
||||||
|
ja_coordenou_antes=cc.ja_coordenou_antes,
|
||||||
|
)
|
||||||
|
for cc in consultor.coordenacoes_capes
|
||||||
|
],
|
||||||
|
coordenacoes_programas=[
|
||||||
|
CoordenacaoProgramaDTO(
|
||||||
|
id_programa=cp.id_programa,
|
||||||
|
nome_programa=cp.nome_programa,
|
||||||
|
codigo_programa=cp.codigo_programa,
|
||||||
|
nota_ppg=cp.nota_ppg,
|
||||||
|
modalidade=cp.modalidade,
|
||||||
|
area_avaliacao=cp.area_avaliacao,
|
||||||
|
periodo=PeriodoDTO(
|
||||||
|
inicio=cp.periodo.inicio.isoformat(),
|
||||||
|
fim=cp.periodo.fim.isoformat() if cp.periodo.fim else None,
|
||||||
|
ativo=cp.periodo.ativo,
|
||||||
|
anos_decorridos=cp.periodo.anos_decorridos,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
for cp in consultor.coordenacoes_programas
|
||||||
|
],
|
||||||
|
consultoria=ConsultoriaDTO(
|
||||||
|
total_eventos=consultor.consultoria.total_eventos,
|
||||||
|
eventos_recentes=consultor.consultoria.eventos_recentes,
|
||||||
|
primeiro_evento=consultor.consultoria.primeiro_evento.isoformat(),
|
||||||
|
ultimo_evento=consultor.consultoria.ultimo_evento.isoformat(),
|
||||||
|
vezes_responsavel=consultor.consultoria.vezes_responsavel,
|
||||||
|
areas=consultor.consultoria.areas,
|
||||||
|
)
|
||||||
|
if consultor.consultoria
|
||||||
|
else None,
|
||||||
|
premiacoes=[
|
||||||
|
PremiacaoDTO(
|
||||||
|
tipo=p.tipo,
|
||||||
|
nome_premio=p.nome_premio,
|
||||||
|
ano=p.ano,
|
||||||
|
pontos=p.pontos,
|
||||||
|
)
|
||||||
|
for p in consultor.premiacoes
|
||||||
|
],
|
||||||
|
pontuacao=PontuacaoCompletaDTO(
|
||||||
|
componente_a=ComponentePontuacaoDTO(
|
||||||
|
base=consultor.pontuacao.componente_a.base,
|
||||||
|
tempo=consultor.pontuacao.componente_a.tempo,
|
||||||
|
extras=consultor.pontuacao.componente_a.extras,
|
||||||
|
bonus=consultor.pontuacao.componente_a.bonus,
|
||||||
|
retorno=consultor.pontuacao.componente_a.retorno,
|
||||||
|
total=consultor.pontuacao.componente_a.total,
|
||||||
|
),
|
||||||
|
componente_b=ComponentePontuacaoDTO(
|
||||||
|
base=consultor.pontuacao.componente_b.base,
|
||||||
|
tempo=consultor.pontuacao.componente_b.tempo,
|
||||||
|
extras=consultor.pontuacao.componente_b.extras,
|
||||||
|
bonus=consultor.pontuacao.componente_b.bonus,
|
||||||
|
retorno=0,
|
||||||
|
total=consultor.pontuacao.componente_b.total,
|
||||||
|
),
|
||||||
|
componente_c=ComponentePontuacaoDTO(
|
||||||
|
base=consultor.pontuacao.componente_c.base,
|
||||||
|
tempo=consultor.pontuacao.componente_c.tempo,
|
||||||
|
extras=consultor.pontuacao.componente_c.extras,
|
||||||
|
bonus=consultor.pontuacao.componente_c.bonus,
|
||||||
|
retorno=0,
|
||||||
|
total=consultor.pontuacao.componente_c.total,
|
||||||
|
),
|
||||||
|
componente_d=ComponentePontuacaoDTO(
|
||||||
|
base=consultor.pontuacao.componente_d.base,
|
||||||
|
tempo=consultor.pontuacao.componente_d.tempo,
|
||||||
|
extras=consultor.pontuacao.componente_d.extras,
|
||||||
|
bonus=consultor.pontuacao.componente_d.bonus,
|
||||||
|
retorno=0,
|
||||||
|
total=consultor.pontuacao.componente_d.total,
|
||||||
|
),
|
||||||
|
pontuacao_total=consultor.pontuacao.total,
|
||||||
|
),
|
||||||
|
rank=rank,
|
||||||
|
)
|
||||||
0
backend/src/domain/__init__.py
Normal file
0
backend/src/domain/__init__.py
Normal file
0
backend/src/domain/entities/__init__.py
Normal file
0
backend/src/domain/entities/__init__.py
Normal file
77
backend/src/domain/entities/consultor.py
Normal file
77
backend/src/domain/entities/consultor.py
Normal file
@@ -0,0 +1,77 @@
|
|||||||
|
from dataclasses import dataclass, field
|
||||||
|
from typing import List, Optional
|
||||||
|
from datetime import datetime
|
||||||
|
|
||||||
|
from ..value_objects.periodo import Periodo
|
||||||
|
from ..value_objects.pontuacao import PontuacaoCompleta
|
||||||
|
|
||||||
|
|
||||||
|
@dataclass
|
||||||
|
class CoordenacaoCapes:
|
||||||
|
tipo: str
|
||||||
|
area_avaliacao: str
|
||||||
|
periodo: Periodo
|
||||||
|
areas_adicionais: List[str] = field(default_factory=list)
|
||||||
|
ja_coordenou_antes: bool = False
|
||||||
|
|
||||||
|
|
||||||
|
@dataclass
|
||||||
|
class CoordenacaoPrograma:
|
||||||
|
id_programa: int
|
||||||
|
nome_programa: str
|
||||||
|
codigo_programa: str
|
||||||
|
nota_ppg: str
|
||||||
|
modalidade: str
|
||||||
|
area_avaliacao: str
|
||||||
|
periodo: Periodo
|
||||||
|
|
||||||
|
|
||||||
|
@dataclass
|
||||||
|
class Consultoria:
|
||||||
|
total_eventos: int
|
||||||
|
eventos_recentes: int
|
||||||
|
primeiro_evento: datetime
|
||||||
|
ultimo_evento: datetime
|
||||||
|
vezes_responsavel: int
|
||||||
|
areas: List[str] = field(default_factory=list)
|
||||||
|
|
||||||
|
|
||||||
|
@dataclass
|
||||||
|
class Premiacao:
|
||||||
|
tipo: str
|
||||||
|
nome_premio: str
|
||||||
|
ano: int
|
||||||
|
pontos: int
|
||||||
|
|
||||||
|
|
||||||
|
@dataclass
|
||||||
|
class Consultor:
|
||||||
|
id_pessoa: int
|
||||||
|
nome: str
|
||||||
|
cpf: Optional[str] = None
|
||||||
|
coordenacoes_capes: List[CoordenacaoCapes] = field(default_factory=list)
|
||||||
|
coordenacoes_programas: List[CoordenacaoPrograma] = field(default_factory=list)
|
||||||
|
consultoria: Optional[Consultoria] = None
|
||||||
|
premiacoes: List[Premiacao] = field(default_factory=list)
|
||||||
|
pontuacao: Optional[PontuacaoCompleta] = None
|
||||||
|
|
||||||
|
@property
|
||||||
|
def anos_atuacao(self) -> float:
|
||||||
|
if not self.consultoria:
|
||||||
|
return 0.0
|
||||||
|
dias = (datetime.now() - self.consultoria.primeiro_evento).days
|
||||||
|
return round(dias / 365.25, 1)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def ativo(self) -> bool:
|
||||||
|
if not self.consultoria:
|
||||||
|
return False
|
||||||
|
return self.consultoria.eventos_recentes > 0
|
||||||
|
|
||||||
|
@property
|
||||||
|
def veterano(self) -> bool:
|
||||||
|
return self.anos_atuacao >= 10.0
|
||||||
|
|
||||||
|
@property
|
||||||
|
def pontuacao_total(self) -> int:
|
||||||
|
return self.pontuacao.total if self.pontuacao else 0
|
||||||
0
backend/src/domain/repositories/__init__.py
Normal file
0
backend/src/domain/repositories/__init__.py
Normal file
26
backend/src/domain/repositories/consultor_repository.py
Normal file
26
backend/src/domain/repositories/consultor_repository.py
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
from abc import ABC, abstractmethod
|
||||||
|
from typing import List, Optional
|
||||||
|
|
||||||
|
from ..entities.consultor import Consultor
|
||||||
|
|
||||||
|
|
||||||
|
class ConsultorRepository(ABC):
|
||||||
|
@abstractmethod
|
||||||
|
async def buscar_por_id(self, id_pessoa: int) -> Optional[Consultor]:
|
||||||
|
pass
|
||||||
|
|
||||||
|
@abstractmethod
|
||||||
|
async def buscar_todos(
|
||||||
|
self, limite: int = 100, offset: int = 0, filtro_ativo: Optional[bool] = None
|
||||||
|
) -> List[Consultor]:
|
||||||
|
pass
|
||||||
|
|
||||||
|
@abstractmethod
|
||||||
|
async def buscar_ranking(
|
||||||
|
self, limite: int = 100, componente: Optional[str] = None
|
||||||
|
) -> List[Consultor]:
|
||||||
|
pass
|
||||||
|
|
||||||
|
@abstractmethod
|
||||||
|
async def contar_total(self, filtro_ativo: Optional[bool] = None) -> int:
|
||||||
|
pass
|
||||||
93
backend/src/domain/services/calculador_pontuacao.py
Normal file
93
backend/src/domain/services/calculador_pontuacao.py
Normal file
@@ -0,0 +1,93 @@
|
|||||||
|
from datetime import datetime, timedelta
|
||||||
|
from typing import List
|
||||||
|
|
||||||
|
from ..entities.consultor import (
|
||||||
|
Consultor,
|
||||||
|
CoordenacaoCapes,
|
||||||
|
CoordenacaoPrograma,
|
||||||
|
Consultoria,
|
||||||
|
Premiacao,
|
||||||
|
)
|
||||||
|
from ..value_objects.pontuacao import ComponentePontuacao, PontuacaoCompleta
|
||||||
|
|
||||||
|
|
||||||
|
class CalculadorPontuacao:
|
||||||
|
@staticmethod
|
||||||
|
def calcular_componente_a(coordenacoes: List[CoordenacaoCapes]) -> ComponentePontuacao:
|
||||||
|
if not coordenacoes:
|
||||||
|
return ComponentePontuacao(base=0, tempo=0, extras=0, bonus=0, retorno=0)
|
||||||
|
|
||||||
|
coord_atual = next((c for c in coordenacoes if c.periodo.ativo), None)
|
||||||
|
if not coord_atual:
|
||||||
|
return ComponentePontuacao(base=0, tempo=0, extras=0, bonus=0, retorno=0)
|
||||||
|
|
||||||
|
base_map = {"CA": 200, "CAJ": 150, "CAJ-MP": 120, "CAM": 100}
|
||||||
|
tempo_max_map = {"CA": 100, "CAJ": 80, "CAJ-MP": 60, "CAM": 50}
|
||||||
|
bonus_atual_map = {"CA": 30, "CAJ": 20, "CAJ-MP": 15, "CAM": 10}
|
||||||
|
|
||||||
|
base = base_map.get(coord_atual.tipo, 0)
|
||||||
|
anos = coord_atual.periodo.anos_decorridos
|
||||||
|
tempo = min(int(anos * 10), tempo_max_map.get(coord_atual.tipo, 0))
|
||||||
|
|
||||||
|
extras = min(len(coord_atual.areas_adicionais) * 20, 100)
|
||||||
|
bonus = bonus_atual_map.get(coord_atual.tipo, 0) if coord_atual.periodo.ativo else 0
|
||||||
|
retorno = 20 if coord_atual.ja_coordenou_antes else 0
|
||||||
|
|
||||||
|
return ComponentePontuacao(base=base, tempo=tempo, extras=extras, bonus=bonus, retorno=retorno)
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def calcular_componente_b(coordenacoes: List[CoordenacaoPrograma]) -> ComponentePontuacao:
|
||||||
|
if not coordenacoes:
|
||||||
|
return ComponentePontuacao(base=0, tempo=0, extras=0, bonus=0)
|
||||||
|
|
||||||
|
base = 70
|
||||||
|
anos_totais = sum(c.periodo.anos_decorridos for c in coordenacoes)
|
||||||
|
tempo = min(int(anos_totais * 5), 50)
|
||||||
|
|
||||||
|
programas_distintos = len({c.id_programa for c in coordenacoes})
|
||||||
|
extras = min((programas_distintos - 1) * 20, 40)
|
||||||
|
|
||||||
|
coord_ativa = any(c.periodo.ativo for c in coordenacoes)
|
||||||
|
bonus = 20 if coord_ativa else 0
|
||||||
|
|
||||||
|
return ComponentePontuacao(base=base, tempo=tempo, extras=extras, bonus=bonus)
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def calcular_componente_c(consultoria: Consultoria) -> ComponentePontuacao:
|
||||||
|
if not consultoria:
|
||||||
|
return ComponentePontuacao(base=0, tempo=0, extras=0, bonus=0)
|
||||||
|
|
||||||
|
base = 150 if consultoria.eventos_recentes > 0 else 100
|
||||||
|
|
||||||
|
anos = (datetime.now() - consultoria.primeiro_evento).days / 365.25
|
||||||
|
tempo = min(int(anos * 5), 50)
|
||||||
|
|
||||||
|
extras_eventos = min(consultoria.total_eventos * 2, 20)
|
||||||
|
extras_responsavel = min(consultoria.vezes_responsavel * 5, 25)
|
||||||
|
extras_areas = min((len(consultoria.areas) - 1) * 10, 30) if len(consultoria.areas) > 1 else 0
|
||||||
|
extras = extras_eventos + extras_responsavel + extras_areas
|
||||||
|
|
||||||
|
bonus = 0
|
||||||
|
|
||||||
|
return ComponentePontuacao(base=base, tempo=tempo, extras=extras, bonus=bonus)
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def calcular_componente_d(premiacoes: List[Premiacao]) -> ComponentePontuacao:
|
||||||
|
if not premiacoes:
|
||||||
|
return ComponentePontuacao(base=0, tempo=0, extras=0, bonus=0)
|
||||||
|
|
||||||
|
total_pontos = sum(p.pontos for p in premiacoes)
|
||||||
|
total_pontos = min(total_pontos, 180)
|
||||||
|
|
||||||
|
return ComponentePontuacao(base=total_pontos, tempo=0, extras=0, bonus=0)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def calcular_pontuacao_completa(cls, consultor: Consultor) -> PontuacaoCompleta:
|
||||||
|
comp_a = cls.calcular_componente_a(consultor.coordenacoes_capes)
|
||||||
|
comp_b = cls.calcular_componente_b(consultor.coordenacoes_programas)
|
||||||
|
comp_c = cls.calcular_componente_c(consultor.consultoria)
|
||||||
|
comp_d = cls.calcular_componente_d(consultor.premiacoes)
|
||||||
|
|
||||||
|
return PontuacaoCompleta(
|
||||||
|
componente_a=comp_a, componente_b=comp_b, componente_c=comp_c, componente_d=comp_d
|
||||||
|
)
|
||||||
0
backend/src/domain/value_objects/__init__.py
Normal file
0
backend/src/domain/value_objects/__init__.py
Normal file
23
backend/src/domain/value_objects/periodo.py
Normal file
23
backend/src/domain/value_objects/periodo.py
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
from dataclasses import dataclass
|
||||||
|
from datetime import datetime
|
||||||
|
from typing import Optional
|
||||||
|
|
||||||
|
|
||||||
|
@dataclass(frozen=True)
|
||||||
|
class Periodo:
|
||||||
|
inicio: datetime
|
||||||
|
fim: Optional[datetime] = None
|
||||||
|
|
||||||
|
@property
|
||||||
|
def ativo(self) -> bool:
|
||||||
|
return self.fim is None
|
||||||
|
|
||||||
|
@property
|
||||||
|
def anos_decorridos(self) -> float:
|
||||||
|
fim = self.fim if self.fim else datetime.now()
|
||||||
|
dias = (fim - self.inicio).days
|
||||||
|
return round(dias / 365.25, 1)
|
||||||
|
|
||||||
|
def __post_init__(self) -> None:
|
||||||
|
if self.fim and self.fim < self.inicio:
|
||||||
|
raise ValueError("Data de fim não pode ser anterior à data de início")
|
||||||
67
backend/src/domain/value_objects/pontuacao.py
Normal file
67
backend/src/domain/value_objects/pontuacao.py
Normal file
@@ -0,0 +1,67 @@
|
|||||||
|
from dataclasses import dataclass
|
||||||
|
from typing import Dict
|
||||||
|
|
||||||
|
|
||||||
|
@dataclass(frozen=True)
|
||||||
|
class ComponentePontuacao:
|
||||||
|
base: int
|
||||||
|
tempo: int
|
||||||
|
extras: int
|
||||||
|
bonus: int
|
||||||
|
retorno: int = 0
|
||||||
|
|
||||||
|
@property
|
||||||
|
def total(self) -> int:
|
||||||
|
return self.base + self.tempo + self.extras + self.bonus + self.retorno
|
||||||
|
|
||||||
|
|
||||||
|
@dataclass(frozen=True)
|
||||||
|
class PontuacaoCompleta:
|
||||||
|
componente_a: ComponentePontuacao
|
||||||
|
componente_b: ComponentePontuacao
|
||||||
|
componente_c: ComponentePontuacao
|
||||||
|
componente_d: ComponentePontuacao
|
||||||
|
|
||||||
|
@property
|
||||||
|
def total(self) -> int:
|
||||||
|
return (
|
||||||
|
self.componente_a.total
|
||||||
|
+ self.componente_b.total
|
||||||
|
+ self.componente_c.total
|
||||||
|
+ self.componente_d.total
|
||||||
|
)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def detalhamento(self) -> Dict[str, Dict[str, int]]:
|
||||||
|
return {
|
||||||
|
"componente_a": {
|
||||||
|
"base": self.componente_a.base,
|
||||||
|
"tempo": self.componente_a.tempo,
|
||||||
|
"extras": self.componente_a.extras,
|
||||||
|
"bonus": self.componente_a.bonus,
|
||||||
|
"retorno": self.componente_a.retorno,
|
||||||
|
"total": self.componente_a.total,
|
||||||
|
},
|
||||||
|
"componente_b": {
|
||||||
|
"base": self.componente_b.base,
|
||||||
|
"tempo": self.componente_b.tempo,
|
||||||
|
"extras": self.componente_b.extras,
|
||||||
|
"bonus": self.componente_b.bonus,
|
||||||
|
"total": self.componente_b.total,
|
||||||
|
},
|
||||||
|
"componente_c": {
|
||||||
|
"base": self.componente_c.base,
|
||||||
|
"tempo": self.componente_c.tempo,
|
||||||
|
"extras": self.componente_c.extras,
|
||||||
|
"bonus": self.componente_c.bonus,
|
||||||
|
"total": self.componente_c.total,
|
||||||
|
},
|
||||||
|
"componente_d": {
|
||||||
|
"base": self.componente_d.base,
|
||||||
|
"tempo": self.componente_d.tempo,
|
||||||
|
"extras": self.componente_d.extras,
|
||||||
|
"bonus": self.componente_d.bonus,
|
||||||
|
"total": self.componente_d.total,
|
||||||
|
},
|
||||||
|
"pontuacao_total": self.total,
|
||||||
|
}
|
||||||
0
backend/src/infrastructure/__init__.py
Normal file
0
backend/src/infrastructure/__init__.py
Normal file
104
backend/src/infrastructure/elasticsearch/client.py
Normal file
104
backend/src/infrastructure/elasticsearch/client.py
Normal file
@@ -0,0 +1,104 @@
|
|||||||
|
import httpx
|
||||||
|
from typing import Optional, Dict, Any
|
||||||
|
|
||||||
|
|
||||||
|
class ElasticsearchClient:
|
||||||
|
def __init__(self, url: str, index: str, user: str = "", password: str = ""):
|
||||||
|
self.url = url.rstrip("/")
|
||||||
|
self.index = index
|
||||||
|
self.user = user
|
||||||
|
self.password = password
|
||||||
|
self._client: Optional[httpx.AsyncClient] = None
|
||||||
|
|
||||||
|
async def connect(self) -> None:
|
||||||
|
auth = None
|
||||||
|
if self.user and self.password:
|
||||||
|
auth = httpx.BasicAuth(self.user, self.password)
|
||||||
|
|
||||||
|
self._client = httpx.AsyncClient(
|
||||||
|
auth=auth,
|
||||||
|
headers={
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
"Accept": "application/json"
|
||||||
|
},
|
||||||
|
verify=False,
|
||||||
|
timeout=120.0
|
||||||
|
)
|
||||||
|
|
||||||
|
async def close(self) -> None:
|
||||||
|
if self._client:
|
||||||
|
await self._client.aclose()
|
||||||
|
|
||||||
|
@property
|
||||||
|
def client(self) -> httpx.AsyncClient:
|
||||||
|
if not self._client:
|
||||||
|
raise RuntimeError("Cliente Elasticsearch não conectado. Execute connect() primeiro.")
|
||||||
|
return self._client
|
||||||
|
|
||||||
|
async def buscar_por_id(self, id_pessoa: int) -> Optional[dict]:
|
||||||
|
try:
|
||||||
|
query = {
|
||||||
|
"query": {"term": {"id": id_pessoa}},
|
||||||
|
"_source": ["id", "dadosPessoais", "atuacoes"],
|
||||||
|
"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", [])
|
||||||
|
return hits[0]["_source"] if hits else None
|
||||||
|
except Exception as e:
|
||||||
|
raise RuntimeError(f"Erro ao buscar consultor {id_pessoa}: {e}")
|
||||||
|
|
||||||
|
async def buscar_com_atuacoes(self, size: int = 1000, from_: int = 0) -> list:
|
||||||
|
try:
|
||||||
|
query = {
|
||||||
|
"query": {
|
||||||
|
"nested": {
|
||||||
|
"path": "atuacoes",
|
||||||
|
"query": {"exists": {"field": "atuacoes.tipo"}}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"_source": ["id", "dadosPessoais", "atuacoes"],
|
||||||
|
"size": size,
|
||||||
|
"from": from_,
|
||||||
|
"sort": [{"id": "asc"}],
|
||||||
|
}
|
||||||
|
|
||||||
|
response = await self.client.post(
|
||||||
|
f"{self.url}/{self.index}/_search",
|
||||||
|
json=query
|
||||||
|
)
|
||||||
|
response.raise_for_status()
|
||||||
|
|
||||||
|
data = response.json()
|
||||||
|
return [hit["_source"] for hit in data.get("hits", {}).get("hits", [])]
|
||||||
|
except Exception as e:
|
||||||
|
raise RuntimeError(f"Erro ao buscar consultores: {e}")
|
||||||
|
|
||||||
|
async def contar_com_atuacoes(self) -> int:
|
||||||
|
try:
|
||||||
|
query = {
|
||||||
|
"query": {
|
||||||
|
"nested": {
|
||||||
|
"path": "atuacoes",
|
||||||
|
"query": {"exists": {"field": "atuacoes.tipo"}}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
response = await self.client.post(
|
||||||
|
f"{self.url}/{self.index}/_count",
|
||||||
|
json=query
|
||||||
|
)
|
||||||
|
response.raise_for_status()
|
||||||
|
|
||||||
|
data = response.json()
|
||||||
|
return data.get("count", 0)
|
||||||
|
except Exception as e:
|
||||||
|
raise RuntimeError(f"Erro ao contar consultores: {e}")
|
||||||
0
backend/src/infrastructure/mcp/__init__.py
Normal file
0
backend/src/infrastructure/mcp/__init__.py
Normal file
0
backend/src/infrastructure/oracle/__init__.py
Normal file
0
backend/src/infrastructure/oracle/__init__.py
Normal file
112
backend/src/infrastructure/oracle/client.py
Normal file
112
backend/src/infrastructure/oracle/client.py
Normal file
@@ -0,0 +1,112 @@
|
|||||||
|
import cx_Oracle
|
||||||
|
from typing import List, Dict, Any, Optional
|
||||||
|
from contextlib import contextmanager
|
||||||
|
|
||||||
|
|
||||||
|
class OracleClient:
|
||||||
|
def __init__(self, user: str, password: str, dsn: str):
|
||||||
|
self.user = user
|
||||||
|
self.password = password
|
||||||
|
self.dsn = dsn
|
||||||
|
self._pool: Optional[cx_Oracle.SessionPool] = None
|
||||||
|
self._connected = False
|
||||||
|
|
||||||
|
def connect(self) -> None:
|
||||||
|
try:
|
||||||
|
self._pool = cx_Oracle.SessionPool(
|
||||||
|
user=self.user,
|
||||||
|
password=self.password,
|
||||||
|
dsn=self.dsn,
|
||||||
|
min=2,
|
||||||
|
max=10,
|
||||||
|
increment=1,
|
||||||
|
encoding="UTF-8",
|
||||||
|
)
|
||||||
|
self._connected = True
|
||||||
|
except Exception as e:
|
||||||
|
print(f"AVISO Oracle: {e}")
|
||||||
|
self._connected = False
|
||||||
|
|
||||||
|
def close(self) -> None:
|
||||||
|
if self._pool:
|
||||||
|
try:
|
||||||
|
self._pool.close()
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
|
@property
|
||||||
|
def is_connected(self) -> bool:
|
||||||
|
return self._connected and self._pool is not None
|
||||||
|
|
||||||
|
@contextmanager
|
||||||
|
def get_connection(self):
|
||||||
|
if not self._pool:
|
||||||
|
raise RuntimeError("Pool Oracle não conectado. Execute connect() primeiro.")
|
||||||
|
conn = self._pool.acquire()
|
||||||
|
try:
|
||||||
|
yield conn
|
||||||
|
finally:
|
||||||
|
self._pool.release(conn)
|
||||||
|
|
||||||
|
def executar_query(self, query: str, params: Optional[dict] = None) -> List[Dict[str, Any]]:
|
||||||
|
if not self.is_connected:
|
||||||
|
return []
|
||||||
|
try:
|
||||||
|
with self.get_connection() as conn:
|
||||||
|
cursor = conn.cursor()
|
||||||
|
cursor.execute(query, params or {})
|
||||||
|
columns = [col[0] for col in cursor.description]
|
||||||
|
rows = cursor.fetchall()
|
||||||
|
cursor.close()
|
||||||
|
return [dict(zip(columns, row)) for row in rows]
|
||||||
|
except Exception as e:
|
||||||
|
print(f"AVISO Oracle: falha ao executar query: {e}")
|
||||||
|
self._connected = False
|
||||||
|
return []
|
||||||
|
|
||||||
|
def buscar_coordenacoes_programa(self, id_pessoa: int) -> List[Dict[str, Any]]:
|
||||||
|
query = """
|
||||||
|
SELECT
|
||||||
|
c.ID_PESSOA,
|
||||||
|
c.ID_PROGRAMA_SNPG,
|
||||||
|
p.NM_PROGRAMA,
|
||||||
|
p.CD_PROGRAMA_PPG,
|
||||||
|
p.DS_CONCEITO AS NOTA_PPG,
|
||||||
|
p.NM_PROGRAMA_MODALIDADE,
|
||||||
|
aa.NM_AREA_AVALIACAO,
|
||||||
|
c.DT_INICIO_VIGENCIA,
|
||||||
|
c.DT_FIM_VIGENCIA
|
||||||
|
FROM SUCUPIRA_PAINEL.VM_COORDENADOR c
|
||||||
|
INNER JOIN SUCUPIRA_PAINEL.VM_PROGRAMA_SUCUPIRA p
|
||||||
|
ON c.ID_PROGRAMA_SNPG = p.ID_PROGRAMA
|
||||||
|
LEFT JOIN SUCUPIRA_PAINEL.VM_AREA_CONHECIMENTO ac
|
||||||
|
ON p.ID_AREA_CONHECIMENTO_ATUAL = ac.ID_AREA_CONHECIMENTO
|
||||||
|
LEFT JOIN SUCUPIRA_PAINEL.VM_AREA_AVALIACAO aa
|
||||||
|
ON ac.ID_AREA_AVALIACAO = aa.ID_AREA_AVALIACAO
|
||||||
|
WHERE c.ID_PESSOA = :id_pessoa
|
||||||
|
ORDER BY c.DT_INICIO_VIGENCIA DESC
|
||||||
|
"""
|
||||||
|
return self.executar_query(query, {"id_pessoa": id_pessoa})
|
||||||
|
|
||||||
|
def buscar_todas_coordenacoes_programa(self) -> List[Dict[str, Any]]:
|
||||||
|
query = """
|
||||||
|
SELECT
|
||||||
|
c.ID_PESSOA,
|
||||||
|
c.ID_PROGRAMA_SNPG,
|
||||||
|
p.NM_PROGRAMA,
|
||||||
|
p.CD_PROGRAMA_PPG,
|
||||||
|
p.DS_CONCEITO AS NOTA_PPG,
|
||||||
|
p.NM_PROGRAMA_MODALIDADE,
|
||||||
|
aa.NM_AREA_AVALIACAO,
|
||||||
|
c.DT_INICIO_VIGENCIA,
|
||||||
|
c.DT_FIM_VIGENCIA
|
||||||
|
FROM SUCUPIRA_PAINEL.VM_COORDENADOR c
|
||||||
|
INNER JOIN SUCUPIRA_PAINEL.VM_PROGRAMA_SUCUPIRA p
|
||||||
|
ON c.ID_PROGRAMA_SNPG = p.ID_PROGRAMA
|
||||||
|
LEFT JOIN SUCUPIRA_PAINEL.VM_AREA_CONHECIMENTO ac
|
||||||
|
ON p.ID_AREA_CONHECIMENTO_ATUAL = ac.ID_AREA_CONHECIMENTO
|
||||||
|
LEFT JOIN SUCUPIRA_PAINEL.VM_AREA_AVALIACAO aa
|
||||||
|
ON ac.ID_AREA_AVALIACAO = aa.ID_AREA_AVALIACAO
|
||||||
|
ORDER BY c.ID_PESSOA, c.DT_INICIO_VIGENCIA DESC
|
||||||
|
"""
|
||||||
|
return self.executar_query(query)
|
||||||
@@ -0,0 +1,287 @@
|
|||||||
|
from typing import List, Optional, Dict, Any
|
||||||
|
from datetime import datetime, timedelta
|
||||||
|
from dateutil import parser as date_parser
|
||||||
|
import asyncio
|
||||||
|
|
||||||
|
from ...domain.entities.consultor import (
|
||||||
|
Consultor,
|
||||||
|
CoordenacaoCapes,
|
||||||
|
CoordenacaoPrograma,
|
||||||
|
Consultoria,
|
||||||
|
Premiacao,
|
||||||
|
)
|
||||||
|
from ...domain.repositories.consultor_repository import ConsultorRepository
|
||||||
|
from ...domain.services.calculador_pontuacao import CalculadorPontuacao
|
||||||
|
from ...domain.value_objects.periodo import Periodo
|
||||||
|
from ..elasticsearch.client import ElasticsearchClient
|
||||||
|
from ..oracle.client import OracleClient
|
||||||
|
|
||||||
|
|
||||||
|
class RankingCache:
|
||||||
|
def __init__(self, ttl_seconds: int = 300):
|
||||||
|
self.ttl = ttl_seconds
|
||||||
|
self._cache: List[Consultor] = []
|
||||||
|
self._last_update: Optional[datetime] = None
|
||||||
|
self._loading = False
|
||||||
|
self._lock = asyncio.Lock()
|
||||||
|
|
||||||
|
def is_valid(self) -> bool:
|
||||||
|
if not self._cache or not self._last_update:
|
||||||
|
return False
|
||||||
|
return (datetime.now() - self._last_update).total_seconds() < self.ttl
|
||||||
|
|
||||||
|
def get(self) -> List[Consultor]:
|
||||||
|
return self._cache
|
||||||
|
|
||||||
|
def set(self, consultores: List[Consultor]) -> None:
|
||||||
|
self._cache = consultores
|
||||||
|
self._last_update = datetime.now()
|
||||||
|
|
||||||
|
|
||||||
|
_ranking_cache = RankingCache(ttl_seconds=300)
|
||||||
|
|
||||||
|
|
||||||
|
class ConsultorRepositoryImpl(ConsultorRepository):
|
||||||
|
def __init__(self, es_client: ElasticsearchClient, oracle_client: OracleClient):
|
||||||
|
self.es_client = es_client
|
||||||
|
self.oracle_client = oracle_client
|
||||||
|
self.calculador = CalculadorPontuacao()
|
||||||
|
self.es_disponivel = True
|
||||||
|
|
||||||
|
def _parse_date(self, date_str: Optional[str]) -> Optional[datetime]:
|
||||||
|
if not date_str:
|
||||||
|
return None
|
||||||
|
try:
|
||||||
|
return date_parser.parse(date_str, dayfirst=True)
|
||||||
|
except:
|
||||||
|
return None
|
||||||
|
|
||||||
|
def _extrair_consultoria(self, atuacoes: List[Dict[str, Any]]) -> Optional[Consultoria]:
|
||||||
|
consultorias = [
|
||||||
|
a for a in atuacoes if a.get("tipo") in ["Consultor", "Histórico de Consultoria"]
|
||||||
|
]
|
||||||
|
if not consultorias:
|
||||||
|
return None
|
||||||
|
|
||||||
|
datas_inicio = [
|
||||||
|
self._parse_date(c.get("inicio"))
|
||||||
|
for c in consultorias
|
||||||
|
]
|
||||||
|
datas_inicio = [d for d in datas_inicio if d]
|
||||||
|
|
||||||
|
datas_fim = [
|
||||||
|
self._parse_date(c.get("fim"))
|
||||||
|
for c in consultorias
|
||||||
|
]
|
||||||
|
datas_fim = [d for d in datas_fim if d]
|
||||||
|
|
||||||
|
if not datas_inicio:
|
||||||
|
return None
|
||||||
|
|
||||||
|
limite_recente = datetime.now() - timedelta(days=730)
|
||||||
|
eventos_recentes = sum(1 for d in datas_fim if d >= limite_recente)
|
||||||
|
|
||||||
|
areas = list({c.get("areaAvaliacao", "N/A") for c in consultorias if c.get("areaAvaliacao")})
|
||||||
|
|
||||||
|
vezes_responsavel = sum(1 for c in consultorias if c.get("responsavel", False))
|
||||||
|
|
||||||
|
return Consultoria(
|
||||||
|
total_eventos=len(consultorias),
|
||||||
|
eventos_recentes=eventos_recentes,
|
||||||
|
primeiro_evento=min(datas_inicio),
|
||||||
|
ultimo_evento=max(datas_fim) if datas_fim else datetime.now(),
|
||||||
|
vezes_responsavel=vezes_responsavel,
|
||||||
|
areas=areas,
|
||||||
|
)
|
||||||
|
|
||||||
|
def _extrair_coordenacoes_capes(
|
||||||
|
self, atuacoes: List[Dict[str, Any]]
|
||||||
|
) -> List[CoordenacaoCapes]:
|
||||||
|
coordenacoes = [
|
||||||
|
a
|
||||||
|
for a in atuacoes
|
||||||
|
if a.get("tipo")
|
||||||
|
in [
|
||||||
|
"Coordenação de Área de Avaliação",
|
||||||
|
"Histórico de Coordenação de Área de Avaliação",
|
||||||
|
]
|
||||||
|
]
|
||||||
|
|
||||||
|
resultado = []
|
||||||
|
for coord in coordenacoes:
|
||||||
|
inicio = self._parse_date(coord.get("inicio"))
|
||||||
|
if not inicio:
|
||||||
|
continue
|
||||||
|
|
||||||
|
tipo = self._inferir_tipo_coordenacao(coord)
|
||||||
|
fim = self._parse_date(coord.get("fim"))
|
||||||
|
|
||||||
|
resultado.append(
|
||||||
|
CoordenacaoCapes(
|
||||||
|
tipo=tipo,
|
||||||
|
area_avaliacao=coord.get("areaAvaliacao", "N/A"),
|
||||||
|
periodo=Periodo(inicio=inicio, fim=fim),
|
||||||
|
areas_adicionais=[],
|
||||||
|
ja_coordenou_antes=False,
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
return resultado
|
||||||
|
|
||||||
|
def _inferir_tipo_coordenacao(self, coord: Dict[str, Any]) -> str:
|
||||||
|
nome = coord.get("nome", "").lower()
|
||||||
|
if "câmara" in nome or "camara" in nome:
|
||||||
|
return "CAM"
|
||||||
|
elif "mestrado profissional" in nome:
|
||||||
|
return "CAJ-MP"
|
||||||
|
elif "adjunta" in nome:
|
||||||
|
return "CAJ"
|
||||||
|
else:
|
||||||
|
return "CA"
|
||||||
|
|
||||||
|
def _extrair_premiacoes(self, atuacoes: List[Dict[str, Any]]) -> List[Premiacao]:
|
||||||
|
premiacoes_data = [
|
||||||
|
a
|
||||||
|
for a in atuacoes
|
||||||
|
if a.get("tipo")
|
||||||
|
in [
|
||||||
|
"Premiação Prêmio",
|
||||||
|
"Avaliação Prêmio",
|
||||||
|
"Inscrição Prêmio",
|
||||||
|
]
|
||||||
|
]
|
||||||
|
|
||||||
|
premiacoes = []
|
||||||
|
for prem in premiacoes_data:
|
||||||
|
pontos = self._calcular_pontos_premiacao(prem.get("tipo", ""))
|
||||||
|
inicio = self._parse_date(prem.get("inicio"))
|
||||||
|
ano = inicio.year if inicio else datetime.now().year
|
||||||
|
|
||||||
|
premiacoes.append(
|
||||||
|
Premiacao(
|
||||||
|
tipo=prem.get("tipo", "N/A"),
|
||||||
|
nome_premio=prem.get("descricao", "N/A"),
|
||||||
|
ano=ano,
|
||||||
|
pontos=pontos,
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
return premiacoes
|
||||||
|
|
||||||
|
def _calcular_pontos_premiacao(self, tipo: str) -> int:
|
||||||
|
mapa = {
|
||||||
|
"Premiação Prêmio": 60,
|
||||||
|
"Avaliação Prêmio": 40,
|
||||||
|
"Inscrição Prêmio": 20,
|
||||||
|
}
|
||||||
|
return mapa.get(tipo, 0)
|
||||||
|
|
||||||
|
async def _construir_consultor(self, doc: Dict[str, Any]) -> Consultor:
|
||||||
|
id_pessoa = doc["id"]
|
||||||
|
dados_pessoais = doc.get("dadosPessoais", {})
|
||||||
|
atuacoes = doc.get("atuacoes", [])
|
||||||
|
|
||||||
|
consultoria = self._extrair_consultoria(atuacoes)
|
||||||
|
coordenacoes_capes = self._extrair_coordenacoes_capes(atuacoes)
|
||||||
|
premiacoes = self._extrair_premiacoes(atuacoes)
|
||||||
|
|
||||||
|
coordenacoes_programas_raw = []
|
||||||
|
if self.oracle_client.is_connected:
|
||||||
|
try:
|
||||||
|
coordenacoes_programas_raw = self.oracle_client.buscar_coordenacoes_programa(id_pessoa)
|
||||||
|
except Exception as e:
|
||||||
|
print(f"AVISO Oracle: erro ao buscar coordenacoes do programa para {id_pessoa}: {e}")
|
||||||
|
coordenacoes_programas = [
|
||||||
|
CoordenacaoPrograma(
|
||||||
|
id_programa=c["ID_PROGRAMA_SNPG"],
|
||||||
|
nome_programa=c["NM_PROGRAMA"],
|
||||||
|
codigo_programa=c["CD_PROGRAMA_PPG"],
|
||||||
|
nota_ppg=c["NOTA_PPG"] or "N/A",
|
||||||
|
modalidade=c["NM_PROGRAMA_MODALIDADE"] or "N/A",
|
||||||
|
area_avaliacao=c["NM_AREA_AVALIACAO"] or "N/A",
|
||||||
|
periodo=Periodo(
|
||||||
|
inicio=c["DT_INICIO_VIGENCIA"],
|
||||||
|
fim=c["DT_FIM_VIGENCIA"],
|
||||||
|
),
|
||||||
|
)
|
||||||
|
for c in coordenacoes_programas_raw
|
||||||
|
]
|
||||||
|
|
||||||
|
consultor = Consultor(
|
||||||
|
id_pessoa=id_pessoa,
|
||||||
|
nome=dados_pessoais.get("nome", "N/A"),
|
||||||
|
cpf=dados_pessoais.get("cpf"),
|
||||||
|
coordenacoes_capes=coordenacoes_capes,
|
||||||
|
coordenacoes_programas=coordenacoes_programas,
|
||||||
|
consultoria=consultoria,
|
||||||
|
premiacoes=premiacoes,
|
||||||
|
)
|
||||||
|
|
||||||
|
consultor.pontuacao = self.calculador.calcular_pontuacao_completa(consultor)
|
||||||
|
|
||||||
|
return consultor
|
||||||
|
|
||||||
|
async def buscar_por_id(self, id_pessoa: int) -> Optional[Consultor]:
|
||||||
|
try:
|
||||||
|
doc = await self.es_client.buscar_por_id(id_pessoa)
|
||||||
|
except Exception as e:
|
||||||
|
print(f"AVISO Elasticsearch: falha ao buscar consultor {id_pessoa}: {e}")
|
||||||
|
return None
|
||||||
|
if not doc:
|
||||||
|
return None
|
||||||
|
return await self._construir_consultor(doc)
|
||||||
|
|
||||||
|
async def buscar_todos(
|
||||||
|
self, limite: int = 100, offset: int = 0, filtro_ativo: Optional[bool] = None
|
||||||
|
) -> List[Consultor]:
|
||||||
|
if not self.es_client._client or getattr(self.es_client._client, "is_closed", False):
|
||||||
|
self.es_disponivel = False
|
||||||
|
return []
|
||||||
|
try:
|
||||||
|
docs = await self.es_client.buscar_com_atuacoes(size=limite, from_=offset)
|
||||||
|
self.es_disponivel = True
|
||||||
|
except Exception as e:
|
||||||
|
print(f"AVISO Elasticsearch: falha ao buscar consultores: {e}")
|
||||||
|
self.es_disponivel = False
|
||||||
|
return []
|
||||||
|
consultores = [await self._construir_consultor(doc) for doc in docs]
|
||||||
|
|
||||||
|
if filtro_ativo is not None:
|
||||||
|
consultores = [c for c in consultores if c.ativo == filtro_ativo]
|
||||||
|
|
||||||
|
return consultores
|
||||||
|
|
||||||
|
async def buscar_ranking(
|
||||||
|
self, limite: int = 100, componente: Optional[str] = None
|
||||||
|
) -> List[Consultor]:
|
||||||
|
global _ranking_cache
|
||||||
|
|
||||||
|
if _ranking_cache.is_valid():
|
||||||
|
consultores_ordenados = _ranking_cache.get()
|
||||||
|
return consultores_ordenados[:limite]
|
||||||
|
|
||||||
|
async with _ranking_cache._lock:
|
||||||
|
if _ranking_cache.is_valid():
|
||||||
|
return _ranking_cache.get()[:limite]
|
||||||
|
|
||||||
|
tamanho_busca = 1000
|
||||||
|
consultores = await self.buscar_todos(limite=tamanho_busca)
|
||||||
|
consultores_ordenados = sorted(
|
||||||
|
consultores, key=lambda c: c.pontuacao_total, reverse=True
|
||||||
|
)
|
||||||
|
_ranking_cache.set(consultores_ordenados)
|
||||||
|
|
||||||
|
return consultores_ordenados[:limite]
|
||||||
|
|
||||||
|
async def contar_total(self, filtro_ativo: Optional[bool] = None) -> int:
|
||||||
|
if not self.es_disponivel:
|
||||||
|
return 0
|
||||||
|
if not self.es_client._client or getattr(self.es_client._client, "is_closed", False):
|
||||||
|
self.es_disponivel = False
|
||||||
|
return 0
|
||||||
|
try:
|
||||||
|
return await self.es_client.contar_com_atuacoes()
|
||||||
|
except Exception as e:
|
||||||
|
print(f"AVISO Elasticsearch: falha ao contar consultores: {e}")
|
||||||
|
self.es_disponivel = False
|
||||||
|
return 0
|
||||||
0
backend/src/interface/__init__.py
Normal file
0
backend/src/interface/__init__.py
Normal file
0
backend/src/interface/api/__init__.py
Normal file
0
backend/src/interface/api/__init__.py
Normal file
50
backend/src/interface/api/app.py
Normal file
50
backend/src/interface/api/app.py
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
from fastapi import FastAPI
|
||||||
|
from fastapi.middleware.cors import CORSMiddleware
|
||||||
|
from contextlib import asynccontextmanager
|
||||||
|
|
||||||
|
from .routes import router
|
||||||
|
from .config import settings
|
||||||
|
from .dependencies import es_client, oracle_client
|
||||||
|
|
||||||
|
|
||||||
|
@asynccontextmanager
|
||||||
|
async def lifespan(app: FastAPI):
|
||||||
|
await es_client.connect()
|
||||||
|
try:
|
||||||
|
oracle_client.connect()
|
||||||
|
except Exception as e:
|
||||||
|
print(f"AVISO: Oracle não conectou: {e}. Sistema rodando sem Coordenação PPG.")
|
||||||
|
yield
|
||||||
|
await es_client.close()
|
||||||
|
try:
|
||||||
|
oracle_client.close()
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
app = FastAPI(
|
||||||
|
title="Ranking de Consultores CAPES",
|
||||||
|
description="Sistema de Ranking de Consultores CAPES baseado na Minuta Técnica",
|
||||||
|
version="1.0.0",
|
||||||
|
lifespan=lifespan,
|
||||||
|
)
|
||||||
|
|
||||||
|
app.add_middleware(
|
||||||
|
CORSMiddleware,
|
||||||
|
allow_origins=settings.cors_origins_list,
|
||||||
|
allow_credentials=True,
|
||||||
|
allow_methods=["*"],
|
||||||
|
allow_headers=["*"],
|
||||||
|
)
|
||||||
|
|
||||||
|
app.include_router(router)
|
||||||
|
|
||||||
|
|
||||||
|
@app.get("/")
|
||||||
|
async def root():
|
||||||
|
return {
|
||||||
|
"message": "API Ranking CAPES",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"docs": "/docs",
|
||||||
|
"health": "/api/v1/health",
|
||||||
|
}
|
||||||
30
backend/src/interface/api/config.py
Normal file
30
backend/src/interface/api/config.py
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
from pydantic_settings import BaseSettings, SettingsConfigDict
|
||||||
|
from typing import List
|
||||||
|
|
||||||
|
|
||||||
|
class Settings(BaseSettings):
|
||||||
|
model_config = SettingsConfigDict(env_file=".env", env_file_encoding="utf-8")
|
||||||
|
|
||||||
|
ES_URL: str = "http://localhost:9200"
|
||||||
|
ES_INDEX: str = "atuacapes__1763197236"
|
||||||
|
ES_USER: str = ""
|
||||||
|
ES_PASSWORD: str = ""
|
||||||
|
|
||||||
|
ORACLE_USER: str
|
||||||
|
ORACLE_PASSWORD: str
|
||||||
|
ORACLE_DSN: str
|
||||||
|
|
||||||
|
API_HOST: str = "0.0.0.0"
|
||||||
|
API_PORT: int = 8000
|
||||||
|
API_RELOAD: bool = True
|
||||||
|
|
||||||
|
CORS_ORIGINS: str = "http://localhost:3000,http://localhost:5173"
|
||||||
|
|
||||||
|
LOG_LEVEL: str = "INFO"
|
||||||
|
|
||||||
|
@property
|
||||||
|
def cors_origins_list(self) -> List[str]:
|
||||||
|
return [origin.strip() for origin in self.CORS_ORIGINS.split(",")]
|
||||||
|
|
||||||
|
|
||||||
|
settings = Settings()
|
||||||
25
backend/src/interface/api/dependencies.py
Normal file
25
backend/src/interface/api/dependencies.py
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
from ...infrastructure.elasticsearch.client import ElasticsearchClient
|
||||||
|
from ...infrastructure.oracle.client import OracleClient
|
||||||
|
from ...infrastructure.repositories.consultor_repository_impl import ConsultorRepositoryImpl
|
||||||
|
from .config import settings
|
||||||
|
|
||||||
|
|
||||||
|
es_client = ElasticsearchClient(
|
||||||
|
url=settings.ES_URL,
|
||||||
|
index=settings.ES_INDEX,
|
||||||
|
user=settings.ES_USER,
|
||||||
|
password=settings.ES_PASSWORD
|
||||||
|
)
|
||||||
|
|
||||||
|
oracle_client = OracleClient(
|
||||||
|
user=settings.ORACLE_USER, password=settings.ORACLE_PASSWORD, dsn=settings.ORACLE_DSN
|
||||||
|
)
|
||||||
|
|
||||||
|
_repository: ConsultorRepositoryImpl = None
|
||||||
|
|
||||||
|
|
||||||
|
def get_repository() -> ConsultorRepositoryImpl:
|
||||||
|
global _repository
|
||||||
|
if _repository is None:
|
||||||
|
_repository = ConsultorRepositoryImpl(es_client=es_client, oracle_client=oracle_client)
|
||||||
|
return _repository
|
||||||
77
backend/src/interface/api/routes.py
Normal file
77
backend/src/interface/api/routes.py
Normal file
@@ -0,0 +1,77 @@
|
|||||||
|
from fastapi import APIRouter, Depends, HTTPException, Query
|
||||||
|
from typing import Optional
|
||||||
|
|
||||||
|
from ...application.use_cases.obter_ranking import ObterRankingUseCase
|
||||||
|
from ...application.use_cases.obter_consultor import ObterConsultorUseCase
|
||||||
|
from ...infrastructure.repositories.consultor_repository_impl import ConsultorRepositoryImpl
|
||||||
|
from ..schemas.consultor_schema import (
|
||||||
|
RankingResponseSchema,
|
||||||
|
RankingDetalhadoResponseSchema,
|
||||||
|
ConsultorDetalhadoSchema,
|
||||||
|
ConsultorResumoSchema,
|
||||||
|
)
|
||||||
|
from .dependencies import get_repository
|
||||||
|
|
||||||
|
router = APIRouter(prefix="/api/v1", tags=["ranking"])
|
||||||
|
|
||||||
|
|
||||||
|
@router.get("/ranking", response_model=RankingResponseSchema)
|
||||||
|
async def obter_ranking(
|
||||||
|
limite: int = Query(default=100, ge=1, le=1000, description="Limite de consultores"),
|
||||||
|
offset: int = Query(default=0, ge=0, description="Offset para paginação"),
|
||||||
|
componente: Optional[str] = Query(
|
||||||
|
default=None, description="Filtrar por componente (a, b, c, d)"
|
||||||
|
),
|
||||||
|
repository: ConsultorRepositoryImpl = Depends(get_repository),
|
||||||
|
):
|
||||||
|
use_case = ObterRankingUseCase(repository=repository)
|
||||||
|
consultores_dto = await use_case.executar(limite=limite, componente=componente)
|
||||||
|
|
||||||
|
total = await repository.contar_total()
|
||||||
|
|
||||||
|
consultores_schema = [
|
||||||
|
ConsultorResumoSchema(**vars(dto)) for dto in consultores_dto
|
||||||
|
]
|
||||||
|
|
||||||
|
return RankingResponseSchema(
|
||||||
|
total=total, limite=limite, offset=offset, consultores=consultores_schema
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@router.get("/ranking/detalhado", response_model=RankingDetalhadoResponseSchema)
|
||||||
|
async def obter_ranking_detalhado(
|
||||||
|
limite: int = Query(default=100, ge=1, le=1000, description="Limite de consultores"),
|
||||||
|
componente: Optional[str] = Query(
|
||||||
|
default=None, description="Filtrar por componente (a, b, c, d)"
|
||||||
|
),
|
||||||
|
repository: ConsultorRepositoryImpl = Depends(get_repository),
|
||||||
|
):
|
||||||
|
use_case = ObterRankingUseCase(repository=repository)
|
||||||
|
consultores_dto = await use_case.executar_detalhado(limite=limite, componente=componente)
|
||||||
|
|
||||||
|
total = await repository.contar_total()
|
||||||
|
|
||||||
|
consultores_schema = [
|
||||||
|
ConsultorDetalhadoSchema(**dto.to_dict()) for dto in consultores_dto
|
||||||
|
]
|
||||||
|
|
||||||
|
return RankingDetalhadoResponseSchema(total=total, limite=limite, consultores=consultores_schema)
|
||||||
|
|
||||||
|
|
||||||
|
@router.get("/consultor/{id_pessoa}", response_model=ConsultorDetalhadoSchema)
|
||||||
|
async def obter_consultor(
|
||||||
|
id_pessoa: int,
|
||||||
|
repository: ConsultorRepositoryImpl = Depends(get_repository),
|
||||||
|
):
|
||||||
|
use_case = ObterConsultorUseCase(repository=repository)
|
||||||
|
consultor = await use_case.executar(id_pessoa=id_pessoa)
|
||||||
|
|
||||||
|
if not consultor:
|
||||||
|
raise HTTPException(status_code=404, detail=f"Consultor {id_pessoa} não encontrado")
|
||||||
|
|
||||||
|
return consultor
|
||||||
|
|
||||||
|
|
||||||
|
@router.get("/health")
|
||||||
|
async def health_check():
|
||||||
|
return {"status": "ok", "message": "API Ranking CAPES funcionando"}
|
||||||
0
backend/src/interface/schemas/__init__.py
Normal file
0
backend/src/interface/schemas/__init__.py
Normal file
98
backend/src/interface/schemas/consultor_schema.py
Normal file
98
backend/src/interface/schemas/consultor_schema.py
Normal file
@@ -0,0 +1,98 @@
|
|||||||
|
from pydantic import BaseModel, Field
|
||||||
|
from typing import List, Optional
|
||||||
|
|
||||||
|
|
||||||
|
class PeriodoSchema(BaseModel):
|
||||||
|
inicio: str
|
||||||
|
fim: Optional[str] = None
|
||||||
|
ativo: bool
|
||||||
|
anos_decorridos: float
|
||||||
|
|
||||||
|
|
||||||
|
class CoordenacaoCapesSchema(BaseModel):
|
||||||
|
tipo: str
|
||||||
|
area_avaliacao: str
|
||||||
|
periodo: PeriodoSchema
|
||||||
|
areas_adicionais: List[str]
|
||||||
|
ja_coordenou_antes: bool
|
||||||
|
|
||||||
|
|
||||||
|
class CoordenacaoProgramaSchema(BaseModel):
|
||||||
|
id_programa: int
|
||||||
|
nome_programa: str
|
||||||
|
codigo_programa: str
|
||||||
|
nota_ppg: str
|
||||||
|
modalidade: str
|
||||||
|
area_avaliacao: str
|
||||||
|
periodo: PeriodoSchema
|
||||||
|
|
||||||
|
|
||||||
|
class ConsultoriaSchema(BaseModel):
|
||||||
|
total_eventos: int
|
||||||
|
eventos_recentes: int
|
||||||
|
primeiro_evento: str
|
||||||
|
ultimo_evento: str
|
||||||
|
vezes_responsavel: int
|
||||||
|
areas: List[str]
|
||||||
|
|
||||||
|
|
||||||
|
class PremiacaoSchema(BaseModel):
|
||||||
|
tipo: str
|
||||||
|
nome_premio: str
|
||||||
|
ano: int
|
||||||
|
pontos: int
|
||||||
|
|
||||||
|
|
||||||
|
class ComponentePontuacaoSchema(BaseModel):
|
||||||
|
base: int
|
||||||
|
tempo: int
|
||||||
|
extras: int
|
||||||
|
bonus: int
|
||||||
|
retorno: int
|
||||||
|
total: int
|
||||||
|
|
||||||
|
|
||||||
|
class PontuacaoCompletaSchema(BaseModel):
|
||||||
|
componente_a: ComponentePontuacaoSchema
|
||||||
|
componente_b: ComponentePontuacaoSchema
|
||||||
|
componente_c: ComponentePontuacaoSchema
|
||||||
|
componente_d: ComponentePontuacaoSchema
|
||||||
|
pontuacao_total: int
|
||||||
|
|
||||||
|
|
||||||
|
class ConsultorResumoSchema(BaseModel):
|
||||||
|
id_pessoa: int
|
||||||
|
nome: str
|
||||||
|
anos_atuacao: float
|
||||||
|
ativo: bool
|
||||||
|
veterano: bool
|
||||||
|
pontuacao_total: int
|
||||||
|
rank: Optional[int] = None
|
||||||
|
|
||||||
|
|
||||||
|
class ConsultorDetalhadoSchema(BaseModel):
|
||||||
|
id_pessoa: int
|
||||||
|
nome: str
|
||||||
|
cpf: Optional[str] = None
|
||||||
|
anos_atuacao: float
|
||||||
|
ativo: bool
|
||||||
|
veterano: bool
|
||||||
|
coordenacoes_capes: List[CoordenacaoCapesSchema]
|
||||||
|
coordenacoes_programas: List[CoordenacaoProgramaSchema]
|
||||||
|
consultoria: Optional[ConsultoriaSchema] = None
|
||||||
|
premiacoes: List[PremiacaoSchema]
|
||||||
|
pontuacao: PontuacaoCompletaSchema
|
||||||
|
rank: Optional[int] = None
|
||||||
|
|
||||||
|
|
||||||
|
class RankingResponseSchema(BaseModel):
|
||||||
|
total: int
|
||||||
|
limite: int
|
||||||
|
offset: int
|
||||||
|
consultores: List[ConsultorResumoSchema]
|
||||||
|
|
||||||
|
|
||||||
|
class RankingDetalhadoResponseSchema(BaseModel):
|
||||||
|
total: int
|
||||||
|
limite: int
|
||||||
|
consultores: List[ConsultorDetalhadoSchema]
|
||||||
12
backend/src/main.py
Normal file
12
backend/src/main.py
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
import uvicorn
|
||||||
|
from interface.api.app import app
|
||||||
|
from interface.api.config import settings
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
uvicorn.run(
|
||||||
|
"interface.api.app:app",
|
||||||
|
host=settings.API_HOST,
|
||||||
|
port=settings.API_PORT,
|
||||||
|
reload=settings.API_RELOAD,
|
||||||
|
log_level=settings.LOG_LEVEL.lower(),
|
||||||
|
)
|
||||||
46
docker-compose.yml
Normal file
46
docker-compose.yml
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
services:
|
||||||
|
backend:
|
||||||
|
container_name: ranking_backend
|
||||||
|
build:
|
||||||
|
context: ./backend
|
||||||
|
dockerfile: Dockerfile
|
||||||
|
ports:
|
||||||
|
- "8000:8000"
|
||||||
|
env_file:
|
||||||
|
- ./backend/.env
|
||||||
|
environment:
|
||||||
|
- API_HOST=0.0.0.0
|
||||||
|
- API_PORT=8000
|
||||||
|
- API_RELOAD=true
|
||||||
|
- CORS_ORIGINS=http://localhost:5173,http://frontend:5173
|
||||||
|
- LOG_LEVEL=INFO
|
||||||
|
volumes:
|
||||||
|
- ./backend/src:/app/src
|
||||||
|
- /etc/localtime:/etc/localtime:ro
|
||||||
|
networks:
|
||||||
|
- shared_network
|
||||||
|
restart: unless-stopped
|
||||||
|
|
||||||
|
frontend:
|
||||||
|
container_name: ranking_frontend
|
||||||
|
build:
|
||||||
|
context: ./frontend
|
||||||
|
dockerfile: Dockerfile
|
||||||
|
depends_on:
|
||||||
|
- backend
|
||||||
|
ports:
|
||||||
|
- "5173:5173"
|
||||||
|
volumes:
|
||||||
|
- ./frontend/src:/app/src
|
||||||
|
- ./frontend/index.html:/app/index.html
|
||||||
|
- ./frontend/vite.config.js:/app/vite.config.js
|
||||||
|
- /etc/localtime:/etc/localtime:ro
|
||||||
|
links:
|
||||||
|
- backend
|
||||||
|
networks:
|
||||||
|
- shared_network
|
||||||
|
restart: unless-stopped
|
||||||
|
|
||||||
|
networks:
|
||||||
|
shared_network:
|
||||||
|
external: true
|
||||||
24
frontend/.gitignore
vendored
Normal file
24
frontend/.gitignore
vendored
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
# Logs
|
||||||
|
logs
|
||||||
|
*.log
|
||||||
|
npm-debug.log*
|
||||||
|
yarn-debug.log*
|
||||||
|
yarn-error.log*
|
||||||
|
pnpm-debug.log*
|
||||||
|
lerna-debug.log*
|
||||||
|
|
||||||
|
node_modules
|
||||||
|
dist
|
||||||
|
dist-ssr
|
||||||
|
*.local
|
||||||
|
|
||||||
|
# Editor directories and files
|
||||||
|
.vscode/*
|
||||||
|
!.vscode/extensions.json
|
||||||
|
.idea
|
||||||
|
.DS_Store
|
||||||
|
*.suo
|
||||||
|
*.ntvs*
|
||||||
|
*.njsproj
|
||||||
|
*.sln
|
||||||
|
*.sw?
|
||||||
12
frontend/Dockerfile
Normal file
12
frontend/Dockerfile
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
FROM node:18-alpine
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
COPY package*.json ./
|
||||||
|
RUN npm install
|
||||||
|
|
||||||
|
COPY . .
|
||||||
|
|
||||||
|
EXPOSE 5173
|
||||||
|
|
||||||
|
CMD ["npm", "run", "dev", "--", "--host", "0.0.0.0"]
|
||||||
16
frontend/README.md
Normal file
16
frontend/README.md
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
# React + Vite
|
||||||
|
|
||||||
|
This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.
|
||||||
|
|
||||||
|
Currently, two official plugins are available:
|
||||||
|
|
||||||
|
- [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react) uses [Babel](https://babeljs.io/) (or [oxc](https://oxc.rs) when used in [rolldown-vite](https://vite.dev/guide/rolldown)) for Fast Refresh
|
||||||
|
- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh
|
||||||
|
|
||||||
|
## React Compiler
|
||||||
|
|
||||||
|
The React Compiler is not enabled on this template because of its impact on dev & build performances. To add it, see [this documentation](https://react.dev/learn/react-compiler/installation).
|
||||||
|
|
||||||
|
## Expanding the ESLint configuration
|
||||||
|
|
||||||
|
If you are developing a production application, we recommend using TypeScript with type-aware lint rules enabled. Check out the [TS template](https://github.com/vitejs/vite/tree/main/packages/create-vite/template-react-ts) for information on how to integrate TypeScript and [`typescript-eslint`](https://typescript-eslint.io) in your project.
|
||||||
29
frontend/eslint.config.js
Normal file
29
frontend/eslint.config.js
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
import js from '@eslint/js'
|
||||||
|
import globals from 'globals'
|
||||||
|
import reactHooks from 'eslint-plugin-react-hooks'
|
||||||
|
import reactRefresh from 'eslint-plugin-react-refresh'
|
||||||
|
import { defineConfig, globalIgnores } from 'eslint/config'
|
||||||
|
|
||||||
|
export default defineConfig([
|
||||||
|
globalIgnores(['dist']),
|
||||||
|
{
|
||||||
|
files: ['**/*.{js,jsx}'],
|
||||||
|
extends: [
|
||||||
|
js.configs.recommended,
|
||||||
|
reactHooks.configs.flat.recommended,
|
||||||
|
reactRefresh.configs.vite,
|
||||||
|
],
|
||||||
|
languageOptions: {
|
||||||
|
ecmaVersion: 2020,
|
||||||
|
globals: globals.browser,
|
||||||
|
parserOptions: {
|
||||||
|
ecmaVersion: 'latest',
|
||||||
|
ecmaFeatures: { jsx: true },
|
||||||
|
sourceType: 'module',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
rules: {
|
||||||
|
'no-unused-vars': ['error', { varsIgnorePattern: '^[A-Z_]' }],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
])
|
||||||
0
frontend/frontend/index.html
Normal file
0
frontend/frontend/index.html
Normal file
0
frontend/frontend/package.json
Normal file
0
frontend/frontend/package.json
Normal file
1
frontend/frontend/src/App.css
Normal file
1
frontend/frontend/src/App.css
Normal file
@@ -0,0 +1 @@
|
|||||||
|
|
||||||
0
frontend/frontend/src/App.jsx
Normal file
0
frontend/frontend/src/App.jsx
Normal file
0
frontend/frontend/src/index.css
Normal file
0
frontend/frontend/src/index.css
Normal file
0
frontend/frontend/src/main.jsx
Normal file
0
frontend/frontend/src/main.jsx
Normal file
0
frontend/frontend/vite.config.js
Normal file
0
frontend/frontend/vite.config.js
Normal file
15
frontend/index.html
Normal file
15
frontend/index.html
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
<!doctype html>
|
||||||
|
<html lang="pt-BR">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8" />
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
|
<link rel="preconnect" href="https://fonts.googleapis.com">
|
||||||
|
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
||||||
|
<link href="https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;600;700&family=Inter:wght@400;500;600&display=swap" rel="stylesheet">
|
||||||
|
<title>Ranking de Consultores CAPES</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div id="root"></div>
|
||||||
|
<script type="module" src="/src/main.jsx"></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
29
frontend/nginx.conf
Normal file
29
frontend/nginx.conf
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
server {
|
||||||
|
listen 80;
|
||||||
|
server_name localhost;
|
||||||
|
root /usr/share/nginx/html;
|
||||||
|
index index.html;
|
||||||
|
|
||||||
|
location / {
|
||||||
|
try_files $uri $uri/ /index.html;
|
||||||
|
}
|
||||||
|
|
||||||
|
location /api {
|
||||||
|
proxy_pass http://backend:8000/api;
|
||||||
|
proxy_http_version 1.1;
|
||||||
|
proxy_set_header Upgrade $http_upgrade;
|
||||||
|
proxy_set_header Connection 'upgrade';
|
||||||
|
proxy_set_header Host $host;
|
||||||
|
proxy_cache_bypass $http_upgrade;
|
||||||
|
proxy_set_header X-Real-IP $remote_addr;
|
||||||
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||||
|
proxy_set_header X-Forwarded-Proto $scheme;
|
||||||
|
}
|
||||||
|
|
||||||
|
gzip on;
|
||||||
|
gzip_vary on;
|
||||||
|
gzip_min_length 10240;
|
||||||
|
gzip_proxied expired no-cache no-store private auth;
|
||||||
|
gzip_types text/plain text/css text/xml text/javascript application/x-javascript application/xml+rss application/json;
|
||||||
|
gzip_disable "MSIE [1-6]\.";
|
||||||
|
}
|
||||||
1796
frontend/package-lock.json
generated
Normal file
1796
frontend/package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
22
frontend/package.json
Normal file
22
frontend/package.json
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
{
|
||||||
|
"name": "ranking-capes-frontend",
|
||||||
|
"private": true,
|
||||||
|
"version": "1.0.0",
|
||||||
|
"type": "module",
|
||||||
|
"scripts": {
|
||||||
|
"dev": "vite",
|
||||||
|
"build": "vite build",
|
||||||
|
"preview": "vite preview"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"react": "^19.2.0",
|
||||||
|
"react-dom": "^19.2.0",
|
||||||
|
"axios": "^1.6.5"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@types/react": "^18.2.0",
|
||||||
|
"@types/react-dom": "^18.2.0",
|
||||||
|
"@vitejs/plugin-react": "^4.2.0",
|
||||||
|
"vite": "^5.0.0"
|
||||||
|
}
|
||||||
|
}
|
||||||
1
frontend/public/vite.svg
Normal file
1
frontend/public/vite.svg
Normal file
@@ -0,0 +1 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="31.88" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 257"><defs><linearGradient id="IconifyId1813088fe1fbc01fb466" x1="-.828%" x2="57.636%" y1="7.652%" y2="78.411%"><stop offset="0%" stop-color="#41D1FF"></stop><stop offset="100%" stop-color="#BD34FE"></stop></linearGradient><linearGradient id="IconifyId1813088fe1fbc01fb467" x1="43.376%" x2="50.316%" y1="2.242%" y2="89.03%"><stop offset="0%" stop-color="#FFEA83"></stop><stop offset="8.333%" stop-color="#FFDD35"></stop><stop offset="100%" stop-color="#FFA800"></stop></linearGradient></defs><path fill="url(#IconifyId1813088fe1fbc01fb466)" d="M255.153 37.938L134.897 252.976c-2.483 4.44-8.862 4.466-11.382.048L.875 37.958c-2.746-4.814 1.371-10.646 6.827-9.67l120.385 21.517a6.537 6.537 0 0 0 2.322-.004l117.867-21.483c5.438-.991 9.574 4.796 6.877 9.62Z"></path><path fill="url(#IconifyId1813088fe1fbc01fb467)" d="M185.432.063L96.44 17.501a3.268 3.268 0 0 0-2.634 3.014l-5.474 92.456a3.268 3.268 0 0 0 3.997 3.378l24.777-5.718c2.318-.535 4.413 1.507 3.936 3.838l-7.361 36.047c-.495 2.426 1.782 4.5 4.151 3.78l15.304-4.649c2.372-.72 4.652 1.36 4.15 3.788l-11.698 56.621c-.732 3.542 3.979 5.473 5.943 2.437l1.313-2.028l72.516-144.72c1.215-2.423-.88-5.186-3.54-4.672l-25.505 4.922c-2.396.462-4.435-1.77-3.759-4.114l16.646-57.705c.677-2.35-1.37-4.583-3.769-4.113Z"></path></svg>
|
||||||
|
After Width: | Height: | Size: 1.5 KiB |
97
frontend/src/App.css
Normal file
97
frontend/src/App.css
Normal file
@@ -0,0 +1,97 @@
|
|||||||
|
.container {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.loading,
|
||||||
|
.error {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
min-height: 60vh;
|
||||||
|
text-align: center;
|
||||||
|
gap: 1rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.loading {
|
||||||
|
font-size: 1.2rem;
|
||||||
|
color: var(--accent-2);
|
||||||
|
}
|
||||||
|
|
||||||
|
.error {
|
||||||
|
background: rgba(255, 59, 48, 0.1);
|
||||||
|
border: 1px solid rgba(255, 59, 48, 0.3);
|
||||||
|
border-radius: 12px;
|
||||||
|
padding: 2rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.error h2 {
|
||||||
|
color: #ff3b30;
|
||||||
|
margin-bottom: 0.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.error button {
|
||||||
|
margin-top: 1rem;
|
||||||
|
padding: 0.6rem 1.2rem;
|
||||||
|
background: var(--accent);
|
||||||
|
border: none;
|
||||||
|
border-radius: 8px;
|
||||||
|
color: white;
|
||||||
|
font-weight: 600;
|
||||||
|
cursor: pointer;
|
||||||
|
transition: background 200ms;
|
||||||
|
}
|
||||||
|
|
||||||
|
.error button:hover {
|
||||||
|
background: var(--accent-2);
|
||||||
|
}
|
||||||
|
|
||||||
|
.controls {
|
||||||
|
margin: 1.5rem 0;
|
||||||
|
display: flex;
|
||||||
|
gap: 1rem;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.controls label {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 0.5rem;
|
||||||
|
font-size: 0.9rem;
|
||||||
|
color: var(--muted);
|
||||||
|
}
|
||||||
|
|
||||||
|
.controls select {
|
||||||
|
padding: 0.5rem 1rem;
|
||||||
|
background: rgba(255,255,255,0.06);
|
||||||
|
border: 1px solid var(--stroke);
|
||||||
|
border-radius: 8px;
|
||||||
|
color: var(--text);
|
||||||
|
font-size: 0.9rem;
|
||||||
|
cursor: pointer;
|
||||||
|
transition: border-color 200ms;
|
||||||
|
}
|
||||||
|
|
||||||
|
.controls select:hover {
|
||||||
|
border-color: var(--accent-2);
|
||||||
|
}
|
||||||
|
|
||||||
|
.ranking-list {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
}
|
||||||
|
|
||||||
|
footer {
|
||||||
|
text-align: center;
|
||||||
|
margin-top: 2.4rem;
|
||||||
|
padding: 1.4rem 0 0.8rem;
|
||||||
|
color: var(--muted);
|
||||||
|
border-top: 1px solid var(--stroke);
|
||||||
|
font-size: 0.9rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
footer p + p {
|
||||||
|
margin-top: 0.5rem;
|
||||||
|
font-size: 0.8rem;
|
||||||
|
}
|
||||||
84
frontend/src/App.jsx
Normal file
84
frontend/src/App.jsx
Normal file
@@ -0,0 +1,84 @@
|
|||||||
|
import { useState, useEffect } from 'react';
|
||||||
|
import Header from './components/Header';
|
||||||
|
import ConsultorCard from './components/ConsultorCard';
|
||||||
|
import { rankingService } from './services/api';
|
||||||
|
import './App.css';
|
||||||
|
|
||||||
|
function App() {
|
||||||
|
const [consultores, setConsultores] = useState([]);
|
||||||
|
const [loading, setLoading] = useState(true);
|
||||||
|
const [error, setError] = useState(null);
|
||||||
|
const [total, setTotal] = useState(0);
|
||||||
|
const [limite, setLimite] = useState(10);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
loadRanking();
|
||||||
|
}, [limite]);
|
||||||
|
|
||||||
|
const loadRanking = async () => {
|
||||||
|
try {
|
||||||
|
setLoading(true);
|
||||||
|
setError(null);
|
||||||
|
const response = await rankingService.getRanking(limite);
|
||||||
|
setConsultores(response.consultores);
|
||||||
|
setTotal(response.total);
|
||||||
|
} catch (err) {
|
||||||
|
console.error('Erro ao carregar ranking:', err);
|
||||||
|
setError('Erro ao carregar ranking. Verifique se a API está rodando.');
|
||||||
|
} finally {
|
||||||
|
setLoading(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
if (loading) {
|
||||||
|
return (
|
||||||
|
<div className="container">
|
||||||
|
<div className="loading">Carregando ranking...</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (error) {
|
||||||
|
return (
|
||||||
|
<div className="container">
|
||||||
|
<div className="error">
|
||||||
|
<h2>Erro</h2>
|
||||||
|
<p>{error}</p>
|
||||||
|
<button onClick={loadRanking}>Tentar novamente</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="container">
|
||||||
|
<Header total={total} />
|
||||||
|
|
||||||
|
<div className="controls">
|
||||||
|
<label>
|
||||||
|
Limite de consultores:
|
||||||
|
<select value={limite} onChange={(e) => setLimite(Number(e.target.value))}>
|
||||||
|
<option value={10}>Top 10</option>
|
||||||
|
<option value={50}>Top 50</option>
|
||||||
|
<option value={100}>Top 100</option>
|
||||||
|
<option value={200}>Top 200</option>
|
||||||
|
<option value={500}>Top 500</option>
|
||||||
|
</select>
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="ranking-list">
|
||||||
|
{consultores.map((consultor) => (
|
||||||
|
<ConsultorCard key={consultor.id_pessoa} consultor={consultor} />
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<footer>
|
||||||
|
<p>Dados: ATUACAPES (Elasticsearch) + SUCUPIRA_PAINEL (Oracle)</p>
|
||||||
|
<p>Critérios: Minuta Técnica - Ranking AtuaCAPES | Clique em qualquer consultor para ver detalhes</p>
|
||||||
|
</footer>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export default App;
|
||||||
1
frontend/src/assets/react.svg
Normal file
1
frontend/src/assets/react.svg
Normal file
@@ -0,0 +1 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="35.93" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 228"><path fill="#00D8FF" d="M210.483 73.824a171.49 171.49 0 0 0-8.24-2.597c.465-1.9.893-3.777 1.273-5.621c6.238-30.281 2.16-54.676-11.769-62.708c-13.355-7.7-35.196.329-57.254 19.526a171.23 171.23 0 0 0-6.375 5.848a155.866 155.866 0 0 0-4.241-3.917C100.759 3.829 77.587-4.822 63.673 3.233C50.33 10.957 46.379 33.89 51.995 62.588a170.974 170.974 0 0 0 1.892 8.48c-3.28.932-6.445 1.924-9.474 2.98C17.309 83.498 0 98.307 0 113.668c0 15.865 18.582 31.778 46.812 41.427a145.52 145.52 0 0 0 6.921 2.165a167.467 167.467 0 0 0-2.01 9.138c-5.354 28.2-1.173 50.591 12.134 58.266c13.744 7.926 36.812-.22 59.273-19.855a145.567 145.567 0 0 0 5.342-4.923a168.064 168.064 0 0 0 6.92 6.314c21.758 18.722 43.246 26.282 56.54 18.586c13.731-7.949 18.194-32.003 12.4-61.268a145.016 145.016 0 0 0-1.535-6.842c1.62-.48 3.21-.974 4.76-1.488c29.348-9.723 48.443-25.443 48.443-41.52c0-15.417-17.868-30.326-45.517-39.844Zm-6.365 70.984c-1.4.463-2.836.91-4.3 1.345c-3.24-10.257-7.612-21.163-12.963-32.432c5.106-11 9.31-21.767 12.459-31.957c2.619.758 5.16 1.557 7.61 2.4c23.69 8.156 38.14 20.213 38.14 29.504c0 9.896-15.606 22.743-40.946 31.14Zm-10.514 20.834c2.562 12.94 2.927 24.64 1.23 33.787c-1.524 8.219-4.59 13.698-8.382 15.893c-8.067 4.67-25.32-1.4-43.927-17.412a156.726 156.726 0 0 1-6.437-5.87c7.214-7.889 14.423-17.06 21.459-27.246c12.376-1.098 24.068-2.894 34.671-5.345a134.17 134.17 0 0 1 1.386 6.193ZM87.276 214.515c-7.882 2.783-14.16 2.863-17.955.675c-8.075-4.657-11.432-22.636-6.853-46.752a156.923 156.923 0 0 1 1.869-8.499c10.486 2.32 22.093 3.988 34.498 4.994c7.084 9.967 14.501 19.128 21.976 27.15a134.668 134.668 0 0 1-4.877 4.492c-9.933 8.682-19.886 14.842-28.658 17.94ZM50.35 144.747c-12.483-4.267-22.792-9.812-29.858-15.863c-6.35-5.437-9.555-10.836-9.555-15.216c0-9.322 13.897-21.212 37.076-29.293c2.813-.98 5.757-1.905 8.812-2.773c3.204 10.42 7.406 21.315 12.477 32.332c-5.137 11.18-9.399 22.249-12.634 32.792a134.718 134.718 0 0 1-6.318-1.979Zm12.378-84.26c-4.811-24.587-1.616-43.134 6.425-47.789c8.564-4.958 27.502 2.111 47.463 19.835a144.318 144.318 0 0 1 3.841 3.545c-7.438 7.987-14.787 17.08-21.808 26.988c-12.04 1.116-23.565 2.908-34.161 5.309a160.342 160.342 0 0 1-1.76-7.887Zm110.427 27.268a347.8 347.8 0 0 0-7.785-12.803c8.168 1.033 15.994 2.404 23.343 4.08c-2.206 7.072-4.956 14.465-8.193 22.045a381.151 381.151 0 0 0-7.365-13.322Zm-45.032-43.861c5.044 5.465 10.096 11.566 15.065 18.186a322.04 322.04 0 0 0-30.257-.006c4.974-6.559 10.069-12.652 15.192-18.18ZM82.802 87.83a323.167 323.167 0 0 0-7.227 13.238c-3.184-7.553-5.909-14.98-8.134-22.152c7.304-1.634 15.093-2.97 23.209-3.984a321.524 321.524 0 0 0-7.848 12.897Zm8.081 65.352c-8.385-.936-16.291-2.203-23.593-3.793c2.26-7.3 5.045-14.885 8.298-22.6a321.187 321.187 0 0 0 7.257 13.246c2.594 4.48 5.28 8.868 8.038 13.147Zm37.542 31.03c-5.184-5.592-10.354-11.779-15.403-18.433c4.902.192 9.899.29 14.978.29c5.218 0 10.376-.117 15.453-.343c-4.985 6.774-10.018 12.97-15.028 18.486Zm52.198-57.817c3.422 7.8 6.306 15.345 8.596 22.52c-7.422 1.694-15.436 3.058-23.88 4.071a382.417 382.417 0 0 0 7.859-13.026a347.403 347.403 0 0 0 7.425-13.565Zm-16.898 8.101a358.557 358.557 0 0 1-12.281 19.815a329.4 329.4 0 0 1-23.444.823c-7.967 0-15.716-.248-23.178-.732a310.202 310.202 0 0 1-12.513-19.846h.001a307.41 307.41 0 0 1-10.923-20.627a310.278 310.278 0 0 1 10.89-20.637l-.001.001a307.318 307.318 0 0 1 12.413-19.761c7.613-.576 15.42-.876 23.31-.876H128c7.926 0 15.743.303 23.354.883a329.357 329.357 0 0 1 12.335 19.695a358.489 358.489 0 0 1 11.036 20.54a329.472 329.472 0 0 1-11 20.722Zm22.56-122.124c8.572 4.944 11.906 24.881 6.52 51.026c-.344 1.668-.73 3.367-1.15 5.09c-10.622-2.452-22.155-4.275-34.23-5.408c-7.034-10.017-14.323-19.124-21.64-27.008a160.789 160.789 0 0 1 5.888-5.4c18.9-16.447 36.564-22.941 44.612-18.3ZM128 90.808c12.625 0 22.86 10.235 22.86 22.86s-10.235 22.86-22.86 22.86s-22.86-10.235-22.86-22.86s10.235-22.86 22.86-22.86Z"></path></svg>
|
||||||
|
After Width: | Height: | Size: 4.0 KiB |
322
frontend/src/components/ConsultorCard.css
Normal file
322
frontend/src/components/ConsultorCard.css
Normal file
@@ -0,0 +1,322 @@
|
|||||||
|
.ranking-card {
|
||||||
|
position: relative;
|
||||||
|
background: linear-gradient(155deg, rgba(255,255,255,0.06), rgba(255,255,255,0.02));
|
||||||
|
border: 1px solid var(--stroke);
|
||||||
|
border-radius: 18px;
|
||||||
|
overflow: hidden;
|
||||||
|
box-shadow: var(--shadow);
|
||||||
|
transition: transform 200ms ease, border 200ms ease, box-shadow 200ms ease;
|
||||||
|
cursor: pointer;
|
||||||
|
margin-bottom: 1rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ranking-card::before {
|
||||||
|
content: "";
|
||||||
|
position: absolute;
|
||||||
|
inset: -40% auto auto -40%;
|
||||||
|
width: 60%;
|
||||||
|
height: 160%;
|
||||||
|
background: radial-gradient(circle at center, rgba(79,70,229,0.18), transparent 55%);
|
||||||
|
transform: rotate(-8deg);
|
||||||
|
opacity: 0.8;
|
||||||
|
pointer-events: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ranking-card:hover {
|
||||||
|
transform: translateY(-4px);
|
||||||
|
border-color: rgba(79,70,229,0.4);
|
||||||
|
box-shadow: 0 15px 35px rgba(0,0,0,0.5);
|
||||||
|
}
|
||||||
|
|
||||||
|
.ranking-card.expanded {
|
||||||
|
border-color: rgba(22,169,250,0.5);
|
||||||
|
box-shadow: 0 22px 38px rgba(0,0,0,0.55);
|
||||||
|
}
|
||||||
|
|
||||||
|
.card-main {
|
||||||
|
position: relative;
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: 70px 1fr auto;
|
||||||
|
align-items: center;
|
||||||
|
gap: 1.35rem;
|
||||||
|
padding: 1.25rem 1.6rem;
|
||||||
|
z-index: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
.rank {
|
||||||
|
width: 62px;
|
||||||
|
height: 62px;
|
||||||
|
display: grid;
|
||||||
|
place-items: center;
|
||||||
|
font-size: 1.35rem;
|
||||||
|
font-weight: 700;
|
||||||
|
color: var(--text);
|
||||||
|
border-radius: 14px;
|
||||||
|
border: 1px solid var(--stroke);
|
||||||
|
background: linear-gradient(145deg, rgba(255,255,255,0.08), rgba(255,255,255,0.03));
|
||||||
|
text-shadow: 0 2px 12px rgba(0,0,0,0.35);
|
||||||
|
}
|
||||||
|
|
||||||
|
.rank-1 {
|
||||||
|
background: linear-gradient(145deg, #fbbf24, #f59e0b);
|
||||||
|
color: #0f172a;
|
||||||
|
}
|
||||||
|
|
||||||
|
.rank-2 {
|
||||||
|
background: linear-gradient(145deg, #cbd5e1, #94a3b8);
|
||||||
|
color: #0f172a;
|
||||||
|
}
|
||||||
|
|
||||||
|
.rank-3 {
|
||||||
|
background: linear-gradient(145deg, #fb923c, #f97316);
|
||||||
|
color: #0f172a;
|
||||||
|
}
|
||||||
|
|
||||||
|
.card-info {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 0.3rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.consultant-name {
|
||||||
|
font-size: 1.15rem;
|
||||||
|
font-weight: 700;
|
||||||
|
letter-spacing: -0.2px;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
gap: 0.65rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.consultant-area {
|
||||||
|
color: var(--muted);
|
||||||
|
font-size: 0.95rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.badge {
|
||||||
|
font-size: 0.72rem;
|
||||||
|
padding: 0.28rem 0.55rem;
|
||||||
|
border-radius: 999px;
|
||||||
|
letter-spacing: 0.4px;
|
||||||
|
border: 1px solid rgba(255,255,255,0.25);
|
||||||
|
text-transform: uppercase;
|
||||||
|
font-weight: 600;
|
||||||
|
}
|
||||||
|
|
||||||
|
.badge-ativo {
|
||||||
|
background: linear-gradient(120deg, var(--success), #16a34a);
|
||||||
|
color: #fff;
|
||||||
|
}
|
||||||
|
|
||||||
|
.badge-historico {
|
||||||
|
background: linear-gradient(120deg, #64748b, #475569);
|
||||||
|
color: #fff;
|
||||||
|
}
|
||||||
|
|
||||||
|
.badge-veterano {
|
||||||
|
background: linear-gradient(120deg, var(--gold), #f59e0b);
|
||||||
|
color: #0f172a;
|
||||||
|
}
|
||||||
|
|
||||||
|
.card-stats {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 1.4rem;
|
||||||
|
background: rgba(255,255,255,0.04);
|
||||||
|
padding: 0.65rem 0.9rem;
|
||||||
|
border-radius: 12px;
|
||||||
|
border: 1px solid var(--stroke);
|
||||||
|
}
|
||||||
|
|
||||||
|
.stat {
|
||||||
|
text-align: center;
|
||||||
|
min-width: 78px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.stat-value {
|
||||||
|
font-size: 1.2rem;
|
||||||
|
font-weight: 700;
|
||||||
|
}
|
||||||
|
|
||||||
|
.stat-label {
|
||||||
|
font-size: 0.72rem;
|
||||||
|
text-transform: uppercase;
|
||||||
|
letter-spacing: 0.6px;
|
||||||
|
color: var(--muted);
|
||||||
|
}
|
||||||
|
|
||||||
|
.score-value {
|
||||||
|
font-size: 1.9rem;
|
||||||
|
font-weight: 800;
|
||||||
|
background: linear-gradient(120deg, var(--accent), var(--accent-2));
|
||||||
|
-webkit-background-clip: text;
|
||||||
|
-webkit-text-fill-color: transparent;
|
||||||
|
background-clip: text;
|
||||||
|
}
|
||||||
|
|
||||||
|
.expand-icon {
|
||||||
|
margin-left: 0.5rem;
|
||||||
|
color: var(--muted);
|
||||||
|
transition: transform 200ms ease, color 200ms ease;
|
||||||
|
font-size: 0.9rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ranking-card:hover .expand-icon {
|
||||||
|
color: var(--accent-2);
|
||||||
|
}
|
||||||
|
|
||||||
|
.ranking-card.expanded .expand-icon {
|
||||||
|
transform: rotate(180deg);
|
||||||
|
color: var(--accent-2);
|
||||||
|
}
|
||||||
|
|
||||||
|
.card-details {
|
||||||
|
padding: 0 1.6rem 1.35rem;
|
||||||
|
border-top: 1px solid var(--stroke);
|
||||||
|
background: linear-gradient(180deg, rgba(255,255,255,0.02), rgba(255,255,255,0));
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
|
||||||
|
.details-grid {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: repeat(5, 1fr);
|
||||||
|
gap: 1.1rem 1.25rem;
|
||||||
|
padding-top: 1.1rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.detail-section {
|
||||||
|
background: rgba(255,255,255,0.04);
|
||||||
|
border: 1px solid var(--stroke);
|
||||||
|
border-radius: 12px;
|
||||||
|
padding: 0.9rem 1rem 0.75rem;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
.detail-section h4 {
|
||||||
|
color: var(--accent-2);
|
||||||
|
font-size: 0.78rem;
|
||||||
|
letter-spacing: 0.9px;
|
||||||
|
text-transform: uppercase;
|
||||||
|
margin-bottom: 0.6rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.score-breakdown,
|
||||||
|
.score-breakdown-total {
|
||||||
|
display: flex;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
gap: 0.55rem;
|
||||||
|
margin-top: 0.4rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.score-breakdown .score-item,
|
||||||
|
.score-breakdown-total .score-item {
|
||||||
|
width: 58px;
|
||||||
|
height: 58px;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.score-item {
|
||||||
|
background: var(--bg-veil);
|
||||||
|
border: 1px solid var(--stroke);
|
||||||
|
border-radius: 10px;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.score-item.score-total {
|
||||||
|
background: linear-gradient(145deg, rgba(79,70,229,0.2), rgba(22,169,250,0.2));
|
||||||
|
border-color: rgba(79,70,229,0.5);
|
||||||
|
}
|
||||||
|
|
||||||
|
.score-item-value {
|
||||||
|
font-size: 1.05rem;
|
||||||
|
font-weight: 700;
|
||||||
|
}
|
||||||
|
|
||||||
|
.score-item-label {
|
||||||
|
font-size: 0.7rem;
|
||||||
|
letter-spacing: 0.8px;
|
||||||
|
color: var(--muted);
|
||||||
|
}
|
||||||
|
|
||||||
|
.extra-details {
|
||||||
|
margin-top: 1.5rem;
|
||||||
|
background: rgba(255,255,255,0.02);
|
||||||
|
border: 1px solid var(--stroke);
|
||||||
|
border-radius: 12px;
|
||||||
|
padding: 1rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.extra-details h4 {
|
||||||
|
color: var(--accent-2);
|
||||||
|
font-size: 0.82rem;
|
||||||
|
letter-spacing: 0.6px;
|
||||||
|
text-transform: uppercase;
|
||||||
|
margin-bottom: 0.8rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.list-items {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 0.6rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.list-item {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 0.8rem;
|
||||||
|
padding: 0.5rem;
|
||||||
|
background: rgba(255,255,255,0.03);
|
||||||
|
border-radius: 8px;
|
||||||
|
font-size: 0.85rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.list-item .muted {
|
||||||
|
color: var(--muted);
|
||||||
|
font-size: 0.8rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 1200px) {
|
||||||
|
.details-grid {
|
||||||
|
grid-template-columns: repeat(3, 1fr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 900px) {
|
||||||
|
.card-main {
|
||||||
|
grid-template-columns: 56px 1fr;
|
||||||
|
align-items: flex-start;
|
||||||
|
}
|
||||||
|
|
||||||
|
.card-stats {
|
||||||
|
width: 100%;
|
||||||
|
justify-content: space-between;
|
||||||
|
margin-top: 0.65rem;
|
||||||
|
grid-column: 1 / -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
.details-grid {
|
||||||
|
grid-template-columns: repeat(2, 1fr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 640px) {
|
||||||
|
.card-stats {
|
||||||
|
flex-wrap: wrap;
|
||||||
|
gap: 0.85rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.stat {
|
||||||
|
flex: 1 1 40%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.score-value {
|
||||||
|
font-size: 1.6rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.details-grid {
|
||||||
|
grid-template-columns: 1fr;
|
||||||
|
}
|
||||||
|
}
|
||||||
216
frontend/src/components/ConsultorCard.jsx
Normal file
216
frontend/src/components/ConsultorCard.jsx
Normal file
@@ -0,0 +1,216 @@
|
|||||||
|
import React, { useState } from 'react';
|
||||||
|
import './ConsultorCard.css';
|
||||||
|
|
||||||
|
const ConsultorCard = ({ consultor }) => {
|
||||||
|
const [expanded, setExpanded] = useState(false);
|
||||||
|
|
||||||
|
const getRankClass = (rank) => {
|
||||||
|
if (rank === 1) return 'rank-1';
|
||||||
|
if (rank === 2) return 'rank-2';
|
||||||
|
if (rank === 3) return 'rank-3';
|
||||||
|
return '';
|
||||||
|
};
|
||||||
|
|
||||||
|
const formatDate = (dateStr) => {
|
||||||
|
if (!dateStr) return 'Atual';
|
||||||
|
return new Date(dateStr).toLocaleDateString('pt-BR');
|
||||||
|
};
|
||||||
|
|
||||||
|
const { pontuacao } = consultor;
|
||||||
|
const { consultoria } = consultor;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className={`ranking-card ${expanded ? 'expanded' : ''}`} onClick={() => setExpanded(!expanded)}>
|
||||||
|
<div className="card-main">
|
||||||
|
<div className={`rank ${getRankClass(consultor.rank)}`}>#{consultor.rank}</div>
|
||||||
|
|
||||||
|
<div className="card-info">
|
||||||
|
<div className="consultant-name">
|
||||||
|
{consultor.nome}
|
||||||
|
{consultor.ativo && <span className="badge badge-ativo">ATIVO</span>}
|
||||||
|
{!consultor.ativo && <span className="badge badge-historico">HISTÓRICO</span>}
|
||||||
|
{consultor.veterano && <span className="badge badge-veterano">VETERANO</span>}
|
||||||
|
</div>
|
||||||
|
<div className="consultant-area">
|
||||||
|
{consultor.anos_atuacao} anos de atuação
|
||||||
|
{consultoria && ` | Desde ${formatDate(consultoria.primeiro_evento)}`}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="card-stats">
|
||||||
|
{consultoria && (
|
||||||
|
<>
|
||||||
|
<div className="stat">
|
||||||
|
<div className="stat-value">{consultoria.total_eventos}</div>
|
||||||
|
<div className="stat-label">Eventos</div>
|
||||||
|
</div>
|
||||||
|
<div className="stat">
|
||||||
|
<div className="stat-value">{consultoria.eventos_recentes}</div>
|
||||||
|
<div className="stat-label">Recentes</div>
|
||||||
|
</div>
|
||||||
|
<div className="stat">
|
||||||
|
<div className="stat-value">{consultoria.vezes_responsavel}</div>
|
||||||
|
<div className="stat-label">Responsável</div>
|
||||||
|
</div>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
<div className="stat">
|
||||||
|
<div className="score-value">{consultor.pontuacao_total}</div>
|
||||||
|
<div className="stat-label">Score</div>
|
||||||
|
</div>
|
||||||
|
<div className="expand-icon">{expanded ? '▲' : '▼'}</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{expanded && (
|
||||||
|
<div className="card-details">
|
||||||
|
<div className="details-grid">
|
||||||
|
<div className="detail-section">
|
||||||
|
<h4>Pontuação Total</h4>
|
||||||
|
<div className="score-breakdown-total">
|
||||||
|
<div className="score-item">
|
||||||
|
<div className="score-item-value" style={{ color: pontuacao.componente_a.total > 0 ? 'var(--accent-2)' : 'var(--muted)' }}>
|
||||||
|
{pontuacao.componente_a.total}
|
||||||
|
</div>
|
||||||
|
<div className="score-item-label">COMP A</div>
|
||||||
|
</div>
|
||||||
|
<div className="score-item">
|
||||||
|
<div className="score-item-value" style={{ color: pontuacao.componente_b.total > 0 ? 'var(--success)' : 'var(--muted)' }}>
|
||||||
|
{pontuacao.componente_b.total}
|
||||||
|
</div>
|
||||||
|
<div className="score-item-label">COMP B</div>
|
||||||
|
</div>
|
||||||
|
<div className="score-item">
|
||||||
|
<div className="score-item-value" style={{ color: pontuacao.componente_c.total > 0 ? 'var(--gold)' : 'var(--muted)' }}>
|
||||||
|
{pontuacao.componente_c.total}
|
||||||
|
</div>
|
||||||
|
<div className="score-item-label">COMP C</div>
|
||||||
|
</div>
|
||||||
|
<div className="score-item">
|
||||||
|
<div className="score-item-value" style={{ color: pontuacao.componente_d.total > 0 ? 'var(--bronze)' : 'var(--muted)' }}>
|
||||||
|
{pontuacao.componente_d.total}
|
||||||
|
</div>
|
||||||
|
<div className="score-item-label">COMP D</div>
|
||||||
|
</div>
|
||||||
|
<div className="score-item score-total">
|
||||||
|
<div className="score-item-value">{pontuacao.pontuacao_total}</div>
|
||||||
|
<div className="score-item-label">TOTAL</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<ComponenteDetalhes
|
||||||
|
titulo="A - Coordenação CAPES"
|
||||||
|
componente={pontuacao.componente_a}
|
||||||
|
cor="var(--accent-2)"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<ComponenteDetalhes
|
||||||
|
titulo="B - Coordenação PPG"
|
||||||
|
componente={pontuacao.componente_b}
|
||||||
|
cor="var(--success)"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<ComponenteDetalhes
|
||||||
|
titulo="C - Consultoria"
|
||||||
|
componente={pontuacao.componente_c}
|
||||||
|
cor="var(--gold)"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<ComponenteDetalhes
|
||||||
|
titulo="D - Premiações"
|
||||||
|
componente={pontuacao.componente_d}
|
||||||
|
cor="var(--bronze)"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{consultor.coordenacoes_capes?.length > 0 && (
|
||||||
|
<div className="extra-details">
|
||||||
|
<h4>Coordenações CAPES</h4>
|
||||||
|
<div className="list-items">
|
||||||
|
{consultor.coordenacoes_capes.map((coord, idx) => (
|
||||||
|
<div key={idx} className="list-item">
|
||||||
|
<span className="badge">{coord.tipo}</span>
|
||||||
|
<span>{coord.area_avaliacao}</span>
|
||||||
|
<span className="muted">
|
||||||
|
{formatDate(coord.periodo.inicio)} - {formatDate(coord.periodo.fim)}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{consultor.coordenacoes_programas?.length > 0 && (
|
||||||
|
<div className="extra-details">
|
||||||
|
<h4>Coordenações de Programa (PPG)</h4>
|
||||||
|
<div className="list-items">
|
||||||
|
{consultor.coordenacoes_programas.map((coord, idx) => (
|
||||||
|
<div key={idx} className="list-item">
|
||||||
|
<span className="badge">{coord.nota_ppg}</span>
|
||||||
|
<span>{coord.nome_programa}</span>
|
||||||
|
<span className="muted">{coord.area_avaliacao}</span>
|
||||||
|
<span className="muted">
|
||||||
|
{formatDate(coord.periodo.inicio)} - {formatDate(coord.periodo.fim)}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{consultor.premiacoes?.length > 0 && (
|
||||||
|
<div className="extra-details">
|
||||||
|
<h4>Premiações</h4>
|
||||||
|
<div className="list-items">
|
||||||
|
{consultor.premiacoes.map((prem, idx) => (
|
||||||
|
<div key={idx} className="list-item">
|
||||||
|
<span className="badge">{prem.pontos} pts</span>
|
||||||
|
<span>{prem.nome_premio}</span>
|
||||||
|
<span className="muted">{prem.ano}</span>
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
const ComponenteDetalhes = ({ titulo, componente, cor }) => (
|
||||||
|
<div className="detail-section">
|
||||||
|
<h4 style={{ color: cor }}>{titulo}</h4>
|
||||||
|
<div className="score-breakdown">
|
||||||
|
<div className="score-item">
|
||||||
|
<div className="score-item-value">{componente.base}</div>
|
||||||
|
<div className="score-item-label">BASE</div>
|
||||||
|
</div>
|
||||||
|
<div className="score-item">
|
||||||
|
<div className="score-item-value">{componente.tempo}</div>
|
||||||
|
<div className="score-item-label">TEMPO</div>
|
||||||
|
</div>
|
||||||
|
<div className="score-item">
|
||||||
|
<div className="score-item-value">{componente.extras}</div>
|
||||||
|
<div className="score-item-label">EXTRAS</div>
|
||||||
|
</div>
|
||||||
|
<div className="score-item">
|
||||||
|
<div className="score-item-value">{componente.bonus}</div>
|
||||||
|
<div className="score-item-label">BÔNUS</div>
|
||||||
|
</div>
|
||||||
|
{componente.retorno > 0 && (
|
||||||
|
<div className="score-item">
|
||||||
|
<div className="score-item-value">{componente.retorno}</div>
|
||||||
|
<div className="score-item-label">RETORNO</div>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
<div className="score-item score-total">
|
||||||
|
<div className="score-item-value">{componente.total}</div>
|
||||||
|
<div className="score-item-label">TOTAL</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
|
||||||
|
export default ConsultorCard;
|
||||||
107
frontend/src/components/Header.css
Normal file
107
frontend/src/components/Header.css
Normal file
@@ -0,0 +1,107 @@
|
|||||||
|
.header {
|
||||||
|
padding: 1.5rem 1.25rem 1.75rem;
|
||||||
|
background: linear-gradient(145deg, rgba(79,70,229,0.18), rgba(22,169,250,0.14));
|
||||||
|
border: 1px solid var(--stroke);
|
||||||
|
border-radius: 18px;
|
||||||
|
box-shadow: var(--shadow);
|
||||||
|
position: relative;
|
||||||
|
overflow: hidden;
|
||||||
|
margin-bottom: 1.75rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.header::after {
|
||||||
|
content: "";
|
||||||
|
position: absolute;
|
||||||
|
inset: 0;
|
||||||
|
background: radial-gradient(circle at 30% 0%, rgba(255,255,255,0.18), transparent 35%);
|
||||||
|
pointer-events: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.header-content {
|
||||||
|
position: relative;
|
||||||
|
z-index: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
.header h1 {
|
||||||
|
font-size: clamp(1.9rem, 3vw, 2.5rem);
|
||||||
|
font-weight: 700;
|
||||||
|
letter-spacing: -0.5px;
|
||||||
|
margin-bottom: 0.35rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.subtitle {
|
||||||
|
color: var(--silver);
|
||||||
|
font-size: 0.95rem;
|
||||||
|
line-height: 1.6;
|
||||||
|
margin-bottom: 0.6rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.meta {
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 0.5rem;
|
||||||
|
margin-top: 0.6rem;
|
||||||
|
padding: 0.4rem 0.75rem;
|
||||||
|
background: rgba(255,255,255,0.08);
|
||||||
|
border: 1px solid var(--stroke);
|
||||||
|
border-radius: 999px;
|
||||||
|
font-size: 0.85rem;
|
||||||
|
color: var(--muted);
|
||||||
|
}
|
||||||
|
|
||||||
|
.criteria-box {
|
||||||
|
background: rgba(79,70,229,0.1);
|
||||||
|
border: 1px solid rgba(79,70,229,0.3);
|
||||||
|
border-radius: 12px;
|
||||||
|
padding: 1rem;
|
||||||
|
margin-top: 1.25rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.criteria-box h3 {
|
||||||
|
color: var(--accent-2);
|
||||||
|
font-size: 0.9rem;
|
||||||
|
margin-bottom: 0.75rem;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.criteria-grid {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
|
||||||
|
gap: 1rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.criteria-section {
|
||||||
|
background: rgba(255,255,255,0.04);
|
||||||
|
border: 1px solid var(--stroke);
|
||||||
|
border-radius: 10px;
|
||||||
|
padding: 0.9rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.criteria-section h4 {
|
||||||
|
color: var(--accent-2);
|
||||||
|
font-size: 0.82rem;
|
||||||
|
margin-bottom: 0.6rem;
|
||||||
|
letter-spacing: 0.4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.criteria-section ul {
|
||||||
|
list-style: none;
|
||||||
|
font-size: 0.8rem;
|
||||||
|
line-height: 1.7;
|
||||||
|
color: var(--muted);
|
||||||
|
}
|
||||||
|
|
||||||
|
.criteria-section li {
|
||||||
|
padding: 0.2rem 0;
|
||||||
|
border-bottom: 1px dashed rgba(255,255,255,0.05);
|
||||||
|
}
|
||||||
|
|
||||||
|
.criteria-section li:last-child {
|
||||||
|
border-bottom: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 768px) {
|
||||||
|
.criteria-grid {
|
||||||
|
grid-template-columns: 1fr;
|
||||||
|
}
|
||||||
|
}
|
||||||
69
frontend/src/components/Header.jsx
Normal file
69
frontend/src/components/Header.jsx
Normal file
@@ -0,0 +1,69 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import './Header.css';
|
||||||
|
|
||||||
|
const Header = ({ total }) => {
|
||||||
|
const dataGeracao = new Date().toLocaleDateString('pt-BR');
|
||||||
|
|
||||||
|
return (
|
||||||
|
<header className="header">
|
||||||
|
<div className="header-content">
|
||||||
|
<h1>Ranking de Consultores CAPES</h1>
|
||||||
|
<p className="subtitle">
|
||||||
|
Sistema completo de pontuação baseado na Minuta Técnica |
|
||||||
|
4 Componentes: Coordenação CAPES + PPG + Consultoria + Premiações
|
||||||
|
</p>
|
||||||
|
<div className="meta">
|
||||||
|
Gerado em {dataGeracao} | Total: {total} consultores
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="criteria-box">
|
||||||
|
<h3>Componentes de Pontuação</h3>
|
||||||
|
<div className="criteria-grid">
|
||||||
|
<div className="criteria-section">
|
||||||
|
<h4>A - Coordenação CAPES (máx 450 pts)</h4>
|
||||||
|
<ul>
|
||||||
|
<li>CA: 200 base + 100 tempo + 100 áreas + 20 retorno + 30 bônus</li>
|
||||||
|
<li>CAJ: 150 base + 80 tempo + 100 áreas + 20 retorno + 20 bônus</li>
|
||||||
|
<li>CAJ-MP: 120 base + 60 tempo + 100 áreas + 20 retorno + 15 bônus</li>
|
||||||
|
<li>CAM: 100 base + 50 tempo + 100 áreas + 20 retorno + 10 bônus</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="criteria-section">
|
||||||
|
<h4>B - Coordenação Programa PPG (máx 180 pts)</h4>
|
||||||
|
<ul>
|
||||||
|
<li>Base: 70 pts</li>
|
||||||
|
<li>Tempo: 5 pts/ano (máx 50 pts)</li>
|
||||||
|
<li>Programas extras: 20 pts/programa (máx 40 pts)</li>
|
||||||
|
<li>Bônus ativo: 20 pts</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="criteria-section">
|
||||||
|
<h4>C - Consultoria (máx 230 pts)</h4>
|
||||||
|
<ul>
|
||||||
|
<li>Ativo: 150 pts base | Histórico: 100 pts base</li>
|
||||||
|
<li>Tempo: 5 pts/ano (máx 50 pts)</li>
|
||||||
|
<li>Eventos: 2 pts/evento (máx 20 pts)</li>
|
||||||
|
<li>Responsável: 5 pts/vez (máx 25 pts)</li>
|
||||||
|
<li>Áreas extras: 10 pts/área (máx 30 pts)</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="criteria-section">
|
||||||
|
<h4>D - Premiações (máx 180 pts)</h4>
|
||||||
|
<ul>
|
||||||
|
<li>Premiação: 60 pts</li>
|
||||||
|
<li>Avaliação: 40 pts</li>
|
||||||
|
<li>Inscrição: 20 pts</li>
|
||||||
|
<li>Total máximo: 180 pts</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</header>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default Header;
|
||||||
49
frontend/src/index.css
Normal file
49
frontend/src/index.css
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
:root {
|
||||||
|
--bg-base: #0b1220;
|
||||||
|
--bg-veil: rgba(255,255,255,0.03);
|
||||||
|
--card: rgba(255,255,255,0.06);
|
||||||
|
--card-strong: rgba(255,255,255,0.12);
|
||||||
|
--stroke: rgba(255,255,255,0.09);
|
||||||
|
--accent: #4f46e5;
|
||||||
|
--accent-2: #16a9fa;
|
||||||
|
--success: #22c55e;
|
||||||
|
--gold: #fbbf24;
|
||||||
|
--silver: #cbd5e1;
|
||||||
|
--bronze: #fb923c;
|
||||||
|
--text: #f8fafc;
|
||||||
|
--muted: #94a3b8;
|
||||||
|
--shadow: 0 25px 50px -12px rgba(0,0,0,0.45);
|
||||||
|
}
|
||||||
|
|
||||||
|
* {
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
box-sizing: border-box;
|
||||||
|
}
|
||||||
|
|
||||||
|
body {
|
||||||
|
font-family: 'Space Grotesk', 'Inter', system-ui, -apple-system, sans-serif;
|
||||||
|
background: radial-gradient(circle at 15% 20%, rgba(79,70,229,0.18), transparent 25%),
|
||||||
|
radial-gradient(circle at 75% 0%, rgba(22,169,250,0.18), transparent 26%),
|
||||||
|
radial-gradient(circle at 80% 80%, rgba(34,197,94,0.12), transparent 30%),
|
||||||
|
var(--bg-base);
|
||||||
|
color: var(--text);
|
||||||
|
min-height: 100vh;
|
||||||
|
padding: 2.25rem;
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
|
||||||
|
body::before {
|
||||||
|
content: "";
|
||||||
|
position: fixed;
|
||||||
|
inset: 0;
|
||||||
|
background: linear-gradient(135deg, rgba(255,255,255,0.04), rgba(255,255,255,0));
|
||||||
|
pointer-events: none;
|
||||||
|
backdrop-filter: blur(12px);
|
||||||
|
z-index: -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
#root {
|
||||||
|
max-width: 1280px;
|
||||||
|
margin: 0 auto;
|
||||||
|
}
|
||||||
10
frontend/src/main.jsx
Normal file
10
frontend/src/main.jsx
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
import { StrictMode } from 'react'
|
||||||
|
import { createRoot } from 'react-dom/client'
|
||||||
|
import './index.css'
|
||||||
|
import App from './App.jsx'
|
||||||
|
|
||||||
|
createRoot(document.getElementById('root')).render(
|
||||||
|
<StrictMode>
|
||||||
|
<App />
|
||||||
|
</StrictMode>,
|
||||||
|
)
|
||||||
29
frontend/src/services/api.js
Normal file
29
frontend/src/services/api.js
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
import axios from 'axios';
|
||||||
|
|
||||||
|
const api = axios.create({
|
||||||
|
baseURL: '/api/v1',
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/json',
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
export const rankingService = {
|
||||||
|
async getRanking(limite = 100, componente = null) {
|
||||||
|
const params = { limite };
|
||||||
|
if (componente) params.componente = componente;
|
||||||
|
const response = await api.get('/ranking/detalhado', { params });
|
||||||
|
return response.data;
|
||||||
|
},
|
||||||
|
|
||||||
|
async getConsultor(idPessoa) {
|
||||||
|
const response = await api.get(`/consultor/${idPessoa}`);
|
||||||
|
return response.data;
|
||||||
|
},
|
||||||
|
|
||||||
|
async getHealth() {
|
||||||
|
const response = await api.get('/health');
|
||||||
|
return response.data;
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
export default api;
|
||||||
16
frontend/vite.config.js
Normal file
16
frontend/vite.config.js
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
import { defineConfig } from 'vite'
|
||||||
|
import react from '@vitejs/plugin-react'
|
||||||
|
|
||||||
|
export default defineConfig({
|
||||||
|
plugins: [react()],
|
||||||
|
server: {
|
||||||
|
host: '0.0.0.0',
|
||||||
|
port: 5173,
|
||||||
|
proxy: {
|
||||||
|
'/api': {
|
||||||
|
target: 'http://backend:8000',
|
||||||
|
changeOrigin: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
152
index-teste.html
Normal file
152
index-teste.html
Normal file
@@ -0,0 +1,152 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="pt-BR">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width,initial-scale=1.0">
|
||||||
|
<title>Ranking de Consultores CAPES - Teste</title>
|
||||||
|
<link rel="preconnect" href="https://fonts.googleapis.com">
|
||||||
|
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
||||||
|
<link href="https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;600;700&family=Inter:wght@400;500;600&display=swap" rel="stylesheet">
|
||||||
|
<style>
|
||||||
|
:root {
|
||||||
|
--bg-base: #0b1220;
|
||||||
|
--stroke: rgba(255,255,255,0.09);
|
||||||
|
--accent: #4f46e5;
|
||||||
|
--accent-2: #16a9fa;
|
||||||
|
--success: #22c55e;
|
||||||
|
--gold: #fbbf24;
|
||||||
|
--text: #f8fafc;
|
||||||
|
--muted: #94a3b8;
|
||||||
|
--shadow: 0 25px 50px -12px rgba(0,0,0,0.45);
|
||||||
|
}
|
||||||
|
* { margin: 0; padding: 0; box-sizing: border-box; }
|
||||||
|
body {
|
||||||
|
font-family: 'Space Grotesk', system-ui;
|
||||||
|
background: radial-gradient(circle at 15% 20%, rgba(79,70,229,0.18), transparent 25%),
|
||||||
|
radial-gradient(circle at 75% 0%, rgba(22,169,250,0.18), transparent 26%),
|
||||||
|
var(--bg-base);
|
||||||
|
color: var(--text);
|
||||||
|
min-height: 100vh;
|
||||||
|
padding: 2.25rem;
|
||||||
|
}
|
||||||
|
.container { max-width: 1280px; margin: 0 auto; }
|
||||||
|
header {
|
||||||
|
padding: 1.5rem;
|
||||||
|
background: linear-gradient(145deg, rgba(79,70,229,0.18), rgba(22,169,250,0.14));
|
||||||
|
border: 1px solid var(--stroke);
|
||||||
|
border-radius: 18px;
|
||||||
|
margin-bottom: 2rem;
|
||||||
|
}
|
||||||
|
h1 { font-size: 2.5rem; margin-bottom: 0.5rem; }
|
||||||
|
.loading { text-align: center; padding: 4rem; font-size: 1.5rem; color: var(--accent-2); }
|
||||||
|
.ranking-card {
|
||||||
|
background: linear-gradient(155deg, rgba(255,255,255,0.06), rgba(255,255,255,0.02));
|
||||||
|
border: 1px solid var(--stroke);
|
||||||
|
border-radius: 18px;
|
||||||
|
padding: 1.5rem;
|
||||||
|
margin-bottom: 1rem;
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: 70px 1fr auto;
|
||||||
|
align-items: center;
|
||||||
|
gap: 1.5rem;
|
||||||
|
cursor: pointer;
|
||||||
|
transition: transform 200ms;
|
||||||
|
}
|
||||||
|
.ranking-card:hover { transform: translateY(-4px); }
|
||||||
|
.rank {
|
||||||
|
width: 62px;
|
||||||
|
height: 62px;
|
||||||
|
display: grid;
|
||||||
|
place-items: center;
|
||||||
|
font-size: 1.35rem;
|
||||||
|
font-weight: 700;
|
||||||
|
border-radius: 14px;
|
||||||
|
background: linear-gradient(145deg, rgba(255,255,255,0.08), rgba(255,255,255,0.03));
|
||||||
|
}
|
||||||
|
.rank-1 { background: linear-gradient(145deg, #fbbf24, #f59e0b); color: #0f172a; }
|
||||||
|
.rank-2 { background: linear-gradient(145deg, #cbd5e1, #94a3b8); color: #0f172a; }
|
||||||
|
.rank-3 { background: linear-gradient(145deg, #fb923c, #f97316); color: #0f172a; }
|
||||||
|
.name { font-size: 1.15rem; font-weight: 700; }
|
||||||
|
.badge {
|
||||||
|
display: inline-block;
|
||||||
|
font-size: 0.7rem;
|
||||||
|
padding: 0.3rem 0.6rem;
|
||||||
|
border-radius: 999px;
|
||||||
|
margin-left: 0.5rem;
|
||||||
|
text-transform: uppercase;
|
||||||
|
}
|
||||||
|
.badge-ativo { background: var(--success); color: white; }
|
||||||
|
.badge-veterano { background: var(--gold); color: #0f172a; }
|
||||||
|
.info { color: var(--muted); font-size: 0.9rem; }
|
||||||
|
.score { font-size: 2rem; font-weight: 800; color: var(--accent-2); }
|
||||||
|
.controls { margin: 1.5rem 0; }
|
||||||
|
.controls select {
|
||||||
|
padding: 0.5rem 1rem;
|
||||||
|
background: rgba(255,255,255,0.06);
|
||||||
|
border: 1px solid var(--stroke);
|
||||||
|
border-radius: 8px;
|
||||||
|
color: var(--text);
|
||||||
|
font-size: 0.9rem;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div class="container">
|
||||||
|
<header>
|
||||||
|
<h1>Ranking de Consultores CAPES</h1>
|
||||||
|
<p>Sistema completo - 4 Componentes (Coordenação CAPES + PPG + Consultoria + Premiações)</p>
|
||||||
|
</header>
|
||||||
|
|
||||||
|
<div class="controls">
|
||||||
|
<label>
|
||||||
|
Limite:
|
||||||
|
<select id="limite" onchange="loadRanking()">
|
||||||
|
<option value="10">Top 10</option>
|
||||||
|
<option value="50">Top 50</option>
|
||||||
|
<option value="100" selected>Top 100</option>
|
||||||
|
</select>
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="ranking" class="ranking-list">
|
||||||
|
<div class="loading">Carregando ranking...</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
async function loadRanking() {
|
||||||
|
const limite = document.getElementById('limite').value;
|
||||||
|
const container = document.getElementById('ranking');
|
||||||
|
container.innerHTML = '<div class="loading">Carregando ranking...</div>';
|
||||||
|
|
||||||
|
try {
|
||||||
|
const response = await fetch(`/api/v1/ranking?limite=${limite}`);
|
||||||
|
const data = await response.json();
|
||||||
|
|
||||||
|
container.innerHTML = '';
|
||||||
|
data.consultores.forEach(c => {
|
||||||
|
const card = document.createElement('div');
|
||||||
|
card.className = 'ranking-card';
|
||||||
|
card.innerHTML = `
|
||||||
|
<div class="rank rank-${c.rank <= 3 ? c.rank : ''}">#${c.rank}</div>
|
||||||
|
<div>
|
||||||
|
<div class="name">
|
||||||
|
${c.nome}
|
||||||
|
${c.ativo ? '<span class="badge badge-ativo">Ativo</span>' : ''}
|
||||||
|
${c.veterano ? '<span class="badge badge-veterano">Veterano</span>' : ''}
|
||||||
|
</div>
|
||||||
|
<div class="info">${c.anos_atuacao} anos de atuação</div>
|
||||||
|
</div>
|
||||||
|
<div class="score">${c.pontuacao_total}</div>
|
||||||
|
`;
|
||||||
|
container.appendChild(card);
|
||||||
|
});
|
||||||
|
} catch (err) {
|
||||||
|
container.innerHTML = `<div class="loading" style="color:red;">Erro: ${err.message}</div>`;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
loadRanking();
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
Reference in New Issue
Block a user