feat: add Pred.gg coach data foundation - #252
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 20e37aeac1
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| const [itemsAlreadySynced, perksAlreadySynced] = await Promise.all([ | ||
| db.gameItemVersion.count({ where: { versionId: version.id } }), | ||
| db.gamePerkVersion.count({ where: { versionId: version.id } }), | ||
| ]); | ||
| if (itemsAlreadySynced > 0 || perksAlreadySynced > 0) continue; |
There was a problem hiding this comment.
Retry partially written catalogs
If syncGameCatalog fails after writing even one item or perk, its non-transactional writes remain in the database; the next tracked-catalog run then sees either count above zero and skips the version permanently. This leaves catalog data incomplete after a transient API or database error, so the skip should depend on a completion marker or verified complete datasets rather than itemsAlreadySynced > 0 || perksAlreadySynced > 0.
Useful? React with 👍 / 👎.
| const candidates = await db.gameItemVersion.findMany({ | ||
| where: { | ||
| versionId: catalogVersionId, isHidden: false, rarity: 'EPIC', slotType: 'PASSIVE', | ||
| }, |
There was a problem hiding this comment.
Select legendary items for completed-build suggestions
The item catalog defines LEGENDARY as the completed-item rarity, and this feature's documentation says suggestions are limited to legendary visible items, but this query selects EPIC. Whenever a build signal requests alternatives, the coach therefore recommends components or misses the intended completed items; filter candidates by LEGENDARY instead.
Useful? React with 👍 / 👎.
| for (const row of selected) { | ||
| const won = row.match.winningTeam === row.team; | ||
| add(heroes, row.heroSlug, won, row.kills, row.deaths, row.assists); |
There was a problem hiding this comment.
Exclude matches whose winner is unknown
For in-progress or incompletely synced matches, winningTeam is explicitly nullable, but this comparison converts every null value into won = false. Those matches are then counted as losses for the player's hero, every enemy matchup, and every ally synergy, which can incorrectly determine the displayed strongest and hardest matchups; omit them from win-rate calculations until a winner is known.
Useful? React with 👍 / 👎.
| <div style={{ marginTop: '0.8rem', padding: '0.8rem', borderRadius: 8, background: 'rgba(34,211,238,0.04)', border: '1px solid rgba(34,211,238,0.16)' }}> | ||
| <div style={{ display: 'flex', justifyContent: 'space-between', gap: '0.6rem', flexWrap: 'wrap' }}> | ||
| <strong style={{ fontSize: '0.78rem' }}>Comparación con jugadores de Pred.gg</strong> | ||
| {benchmark.benchmark.rating?.percentile != null && <span style={{ color: 'var(--accent-cyan)', fontSize: '0.67rem', fontWeight: 700 }}>Top {(benchmark.benchmark.rating.percentile * 100).toFixed(1)}% en Pred.gg</span>} |
There was a problem hiding this comment.
Invert the rating percentile when labeling Top
Pred.gg's rating percentile represents the population below the player, so a value such as 0.42 corresponds to top 58%, as the existing scouting page already computes with 100 - percentile * 100. This new card instead displays top 42%, reversing the user's rank for every non-median percentile.
Useful? React with 👍 / 👎.
Amplía OAuth y telemetría de Pred.gg, modela ancestros y catálogos versionados, añade contexto de champion pool, coach de builds y benchmarks globales con degradación por permisos. Incluye migraciones aditivas, documentación y pruebas. Verificado con 137 tests, build web y datos reales de staging.