Skip to content

Commit 04f0d9d

Browse files
committed
feat: implement pro match details
painel completo de análise pré/pós jogo
1 parent 2084e35 commit 04f0d9d

10 files changed

Lines changed: 415 additions & 74 deletions

File tree

Gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ gem 'rswag-api'
7777
gem 'rswag-ui'
7878

7979
# Elasticsearch client (for analytics queries)
80-
gem 'elasticsearch', '~> 9.1', '>= 9.1.3'
80+
gem 'elasticsearch', '~> 8.19'
8181

8282
# Meilisearch — full-text search for players, organizations, scouting targets, etc.
8383
gem 'meilisearch', '~> 0.33'

Gemfile.lock

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -140,13 +140,14 @@ GEM
140140
railties (>= 6.1)
141141
drb (2.2.3)
142142
ed25519 (1.4.0)
143-
elastic-transport (8.4.1)
143+
elastic-transport (8.5.1)
144144
faraday (< 3)
145145
multi_json
146-
elasticsearch (9.2.0)
146+
elasticsearch (8.19.3)
147147
elastic-transport (~> 8.3)
148-
elasticsearch-api (= 9.2.0)
149-
elasticsearch-api (9.2.0)
148+
elasticsearch-api (= 8.19.3)
149+
ostruct
150+
elasticsearch-api (8.19.3)
150151
multi_json
151152
erb (6.0.2)
152153
erubi (1.13.1)
@@ -245,7 +246,7 @@ GEM
245246
mini_mime (1.1.5)
246247
minitest (5.27.0)
247248
msgpack (1.8.0)
248-
multi_json (1.18.0)
249+
multi_json (1.20.1)
249250
multi_xml (0.8.1)
250251
bigdecimal (>= 3.1, < 5)
251252
multipart-post (2.4.1)
@@ -481,7 +482,7 @@ DEPENDENCIES
481482
database_cleaner-active_record
482483
debug
483484
dotenv-rails
484-
elasticsearch (~> 9.1, >= 9.1.3)
485+
elasticsearch (~> 8.19)
485486
factory_bot_rails
486487
faker
487488
faraday

README.md

Lines changed: 57 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,10 @@
5555
│ [■] VOD Review System — Collaborative timestamp annotations │
5656
│ [■] Schedule Management — Matches, scrims and team events │
5757
│ [■] Goal Tracking — Performance goals (team and players) │
58-
│ [■] Competitive Module — PandaScore integration + draft analysis │
58+
│ [■] Competitive Module — PandaScore + ES match detail + H2H │
59+
│ [■] Match Detail View — Per-game picks, KDA, gold, CS, DMG from ES │
60+
│ [■] Pro Match Data Lake — 97K+ games (2014-2026) in Elasticsearch │
61+
│ [■] Multi-League Backfill — CBLOL · Academy · CD auto-sync daily │
5962
│ [■] Scrims Management — Opponent tracking + analytics │
6063
│ [■] Strategy Module — Draft planning + tactical boards │
6164
│ [■] Meta Intelligence — Build aggregation, champion/item analytics │
@@ -188,6 +191,7 @@ open http://localhost:3333/api-docs
188191
║ Serialization ║ Blueprinter ║
189192
║ Full-text Search ║ Meilisearch ║
190193
║ Real-time ║ Action Cable (WebSocket) ║
194+
║ Data Lake ║ Elasticsearch 8 (97K+ pro games, all leagues) ║
191195
╚══════════════════════╩════════════════════════════════════════════════════╝
192196
```
193197

@@ -213,7 +217,7 @@ This API follows a **modular monolith** architecture:
213217
│ vod_reviews │ Video review and timestamp management │
214218
│ team_goals │ Goal setting and tracking │
215219
│ riot_integration │ Riot Games API integration │
216-
│ competitive │ PandaScore integration, pro matches, draft analysis
220+
│ competitive │ PandaScore + Elasticsearch match detail, H2H, draft
217221
│ meta_intelligence │ Build aggregation, champion/item meta analytics │
218222
│ scrims │ Scrim management and opponent team tracking │
219223
│ strategy │ Draft planning and tactical board system │
@@ -239,7 +243,7 @@ This API follows a modular monolith architecture with the following modules:
239243
- `vod_reviews` - Video review and timestamp management
240244
- `team_goals` - Goal setting and tracking
241245
- `riot_integration` - Riot Games API integration
242-
- `competitive` - PandaScore integration, pro matches, draft analysis
246+
- `competitive` - PandaScore + Elasticsearch match detail, H2H, draft analysis
243247
- `scrims` - Scrim management and opponent team tracking
244248
- `strategy` - Draft planning and tactical board system
245249
- `support` - Support ticket system with staff and FAQ management
@@ -712,7 +716,7 @@ curl -X POST http://localhost:3333/api/v1/auth/refresh \
712716
#### Riot Integration
713717
- `GET /riot-integration/sync-status` — Get sync status for all players
714718

715-
#### Competitive (PandaScore Integration)
719+
#### Competitive (PandaScore + Elasticsearch)
716720
- `GET /competitive-matches` — List competitive matches
717721
- `GET /competitive-matches/:id` — Get competitive match details
718722
- `GET /competitive/pro-matches` — List all pro matches
@@ -721,11 +725,15 @@ curl -X POST http://localhost:3333/api/v1/auth/refresh \
721725
- `GET /competitive/pro-matches/past` — Get past pro matches
722726
- `POST /competitive/pro-matches/refresh` — Refresh pro matches from PandaScore
723727
- `POST /competitive/pro-matches/import` — Import specific pro match
728+
- `GET /competitive/pro-matches/match-preview` — Per-game picks + stats for a recent series (ES)
729+
- `GET /competitive/pro-matches/es-series` — H2H series history between two teams (ES)
724730
- `POST /competitive/draft-comparison` — Compare team compositions
725731
- `GET /competitive/meta/:role` — Get meta champions by role
726732
- `GET /competitive/composition-winrate` — Get composition winrate statistics
727733
- `GET /competitive/counters` — Get champion counter suggestions
728734

735+
> `match-preview` and `es-series` query the Elasticsearch data lake (97K+ games) and are league-agnostic. They accept `?team1=&team2=&league=&limit=` query params.
736+
729737
#### Scrims Management
730738
- `GET /scrims/scrims` — List all scrims
731739
- `GET /scrims/scrims/:id` — Get scrim details
@@ -1176,6 +1184,7 @@ graph TB
11761184
PG[("PostgreSQL")]
11771185
RD[("Redis")]
11781186
Meili[("Meilisearch")]
1187+
ES[("Elasticsearch\n97K+ pro games")]
11791188
end
11801189
11811190
subgraph "External APIs"
@@ -1201,6 +1210,8 @@ graph TB
12011210
Router -- "player data" --> RiotAPI
12021211
Sidekiq -- "match + profile sync" --> RiotAPI
12031212
Router -- "pro matches" --> PandaScore
1213+
Router -- "match detail · H2H" --> ES
1214+
Sidekiq -- "historical backfill" --> ES
12041215
12051216
style FrontendApp fill:#1e88e5
12061217
style PlayerPortal fill:#5c6bc0
@@ -1210,17 +1221,38 @@ graph TB
12101221
style PG fill:#336791
12111222
style RD fill:#d82c20
12121223
style Meili fill:#ff5722
1224+
style ES fill:#005571
12131225
style RiotAPI fill:#eb0029
12141226
style PandaScore fill:#ff6b35
12151227
```
12161228

1229+
### Scheduled Jobs (Sidekiq Scheduler)
1230+
1231+
```
1232+
╔══════════════════════════════╦═══════════════╦═══════════════════════════════════════════╗
1233+
║ Job ║ Schedule ║ Description ║
1234+
╠══════════════════════════════╬═══════════════╬═══════════════════════════════════════════╣
1235+
║ CleanupExpiredTokensJob ║ 0 2 * * * ║ Purge expired JWT blacklist + pwd tokens ║
1236+
║ RefreshMetadataViewsJob ║ 0 */2 * * * ║ Refresh DB metadata materialized views ║
1237+
║ HistoricalBackfillJob ║ 0 4 * * * ║ CBLOL: Leaguepedia → ES → DB ║
1238+
║ HistoricalBackfillJob ║ 30 4 * * * ║ CBLOL Academy: Leaguepedia → ES → DB ║
1239+
║ HistoricalBackfillJob ║ 0 5 * * * ║ Circuito Desafiante: Leaguepedia → ES ║
1240+
║ ScrimResultReminderJob ║ 0 10 * * * ║ Send deadline reminders, expire reports ║
1241+
║ RebuildChampionMatrixJob ║ 0 3 * * * ║ Rebuild AI champion matrices/vectors ║
1242+
║ StatusSnapshotJob ║ */15 * * * * ║ Record component health snapshots ║
1243+
╚══════════════════════════════╩═══════════════╩═══════════════════════════════════════════╝
1244+
```
1245+
1246+
> Backfill jobs are resumable — re-running skips already-completed tournaments. First run imports full history (~8-12h); subsequent runs only process new/failed tournaments (minutes).
1247+
12171248
**Production Stack (Coolify):**
12181249
- **Reverse Proxy**: Traefik with automatic TLS (Let's Encrypt)
12191250
- **WebSocket Support**: Native WebSocket proxy for Action Cable
12201251
- **Application**: Rails 7.2 API (Puma) + Action Cable + Sidekiq
12211252
- **Database**: PostgreSQL 14+ (Supabase self hosted) + Cassandra
12221253
- **Cache/Queue**: Redis 7
12231254
- **Search**: Meilisearch (self-hosted)
1255+
- **Data Lake**: Elasticsearch 8 (self-hosted, 97K+ pro games)
12241256

12251257
**Data Flow:**
12261258
1. Clients connect via HTTPS/WSS through Traefik
@@ -1264,6 +1296,17 @@ AUTH_TRACKER_WINDOW=5 # sliding window in minutes
12641296

12651297
# Circuit breaker (optional, defaults shown)
12661298
CIRCUIT_BREAKER_THRESHOLD=5 # consecutive failures before opening circuit
1299+
1300+
# Elasticsearch data lake
1301+
ELASTICSEARCH_URL=https://user:password@elastic.example.com # ES 8.x with basic auth
1302+
1303+
# Historical backfill (Sidekiq scheduled jobs — override per-job via sidekiq.yml kwargs)
1304+
BACKFILL_LEAGUE=CBLOL # default league for manual runs
1305+
BACKFILL_OUR_TEAM=paiN Gaming # team name used in sync step
1306+
BACKFILL_MIN_YEAR=2013 # earliest year to import
1307+
BACKFILL_SYNC_LIMIT=500 # max matches synced per job run
1308+
SIDEKIQ_CONCURRENCY=10 # Sidekiq thread count (keep DB_POOL equal)
1309+
DB_POOL=10 # ActiveRecord pool size for Sidekiq container
12671310
```
12681311

12691312
### Docker
@@ -1279,16 +1322,16 @@ docker run -p 3333:3000 prostaff-api
12791322

12801323
### CI/CD Workflows
12811324

1282-
| Workflow | Trigger | What it does |
1283-
|------------------------|----------------------------------------------|-------------------------------------------------------------------------------|
1284-
| `security-scan.yml` | Push / PR → master, develop | Brakeman, Bundle Audit, Semgrep, TruffleHog, SSRF + auth + SQLi runtime tests |
1285-
| `codeql.yml` | Push / PR → master + Saturdays 3am UTC | CodeQL `security-extended` + Actions workflows; SARIF to GitHub Security tab |
1286-
| `nightly-security.yml` | Nightly 1am UTC + manual dispatch | Full audit: Brakeman + Bundle Audit + ZAP baseline + ZAP API scan |
1287-
| `load-test.yml` | Manual dispatch | k6 smoke/load/stress tests |
1288-
| `snyk-container.yml` | Push / PR → master, develop + weekly | Snyk container image vulnerability scan |
1289-
| `deploy-production.yml`| Push tag `v*.*.*` + manual dispatch | Build, test, deploy to Coolify + CORS smoke test post-deploy |
1290-
| `deploy-staging.yml` | Push → develop + manual dispatch | Same pipeline targeting staging |
1291-
| `update-architecture-diagram.yml` Push / PR + manual dispatch | Auto-regenerates Mermaid diagram and commits |
1325+
| Workflow | Trigger | What it does |
1326+
|------------------------|-----------------------------------------|-------------------------------------------------------------------------------|
1327+
| `security-scan.yml` | Push / PR → master, develop | Brakeman, Bundle Audit, Semgrep, TruffleHog, SSRF + auth + SQLi runtime tests |
1328+
| `codeql.yml` | Push / PR → master + Saturdays 3am UTC | CodeQL `security-extended` + Actions workflows; SARIF to GitHub Security tab |
1329+
| `nightly-security.yml` | Nightly 1am UTC + manual dispatch | Full audit: Brakeman + Bundle Audit + ZAP baseline + ZAP API scan |
1330+
| `load-test.yml` | Manual dispatch | k6 smoke/load/stress tests |
1331+
| `snyk-container.yml` | Push / PR → master, develop + weekly | Snyk container image vulnerability scan |
1332+
| `deploy-production.yml`| Push tag `v*.*.*` + manual dispatch | Build, test, deploy to Coolify + CORS smoke test post-deploy |
1333+
| `deploy-staging.yml` | Push → develop + manual dispatch | Same pipeline targeting staging |
1334+
| `update-architecture-diagram.yml` Push / PR + manual dispatch | Auto-regenerates Mermaid diagram and commits |
12921335

12931336
### CodeQL Analysis
12941337

0 commit comments

Comments
 (0)