Skip to content

Add weekly lineup optimizer - #281

Merged
sfreeman422 merged 2 commits into
masterfrom
feature/roster-suggestions
Sep 9, 2026
Merged

Add weekly lineup optimizer#281
sfreeman422 merged 2 commits into
masterfrom
feature/roster-suggestions

Conversation

@sfreeman422

Copy link
Copy Markdown
Collaborator

Summary

  • calculate min/max weekly lineup potential from each team's full active roster
  • compare the user's optimized lineup with the Sleeper matchup opponent
  • recommend start/bench changes and add an AI-generated explanation
  • surface a clear unavailable state when Sleeper weekly projections cannot be retrieved

Data source note

Weekly projections come from api.sleeper.com/projections. This endpoint is operational but is not documented with Sleeper's public v1 league API, so the feature fails closed if projection data is missing or unusable.

Testing

  • backend and frontend test suites
  • backend and frontend lint
  • backend and frontend production builds

Use Sleeper matchup and projection data to rank complete lineups against the weekly opponent, then explain recommended start/sit changes with AI.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI lite review requested due to automatic review settings September 9, 2026 16:46

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The current lineup optimization flow can produce and publish incomplete lineups (skipping unfillable slots) and has overly strict lineupSummary validation that can unnecessarily fail AI responses.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

Adds a weekly “lineup optimizer” feature that computes min/max projected lineup potential from Sleeper projections, compares it to the current matchup opponent, and surfaces recommended start/bench changes with an AI-generated explanation (with a fail-closed unavailable state when projections can’t be retrieved).

Changes:

  • Backend: fetches Sleeper weekly projections + matchups, builds an optimized lineup recommendation, and includes a new lineupStatus / lineupRecommendation in the fantasy overview response.
  • Backend: extends the AI response schema to include lineupSummary, and uses a deterministic fallback summary when AI is unavailable.
  • Frontend: renders the lineup optimizer section and updates page tests/types to include the new overview fields.
File summaries
File Description
packages/frontend/src/pages/FantasyPage.tsx Adds lineup optimizer UI section with status-driven empty/unavailable states and lineup details rendering.
packages/frontend/src/pages/FantasyPage.spec.tsx Extends UI test fixtures/assertions to cover the new lineup optimizer section.
packages/frontend/src/app.model.ts Introduces LineupRecommendation types and adds lineupStatus/lineupRecommendation to FantasyOverview.
packages/backend/src/fantasy/fantasy.service.ts Implements projections fetch, lineup optimization/recommendations, and threads lineup summary through AI + overview response.
packages/backend/src/fantasy/fantasy.service.spec.ts Adds coverage for lineup recommendation generation and projections-unavailable behavior.
packages/backend/src/fantasy/fantasy.model.ts Adds Sleeper matchup/projection models and extends API models with lineup recommendation/status + lineupSummary.
Review details

Suppressed comments (1)

packages/backend/src/fantasy/fantasy.service.ts:435

  • opponentPotential is currently computed as long as the optimized lineups are non-empty, which can still be a partial lineup if some slots were skipped. Only publish opponent potential when both min and max lineups fill all starting slots, otherwise leave it null.
      opponentPotential:
        opponentMaximum.length && opponentMinimum.length
          ? {
              min: this.lineupTotal(opponentMinimum),
              max: this.lineupTotal(opponentMaximum),
            }
          : null,
  • Files reviewed: 6/6 changed files
  • Comments generated: 4
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +405 to +409
const maximum = this.optimizeLineup(ownPlayers, slots, 'max');
const minimum = this.optimizeLineup(ownPlayers, slots, 'min');
if (!maximum.length || !minimum.length) {
return null;
}
Comment on lines +866 to 869
!Array.isArray(waiverSuggestions) ||
typeof lineupSummary !== 'string' ||
!lineupSummary.trim()
) {
Comment on lines +279 to +281
summary:
aiStatus === 'ready' ? analysis.lineupSummary : this.buildLineupFallbackSummary(lineupRecommendation),
}
Comment on lines +166 to +169
<h2 className="mb-3 flex items-center gap-2 text-lg font-semibold">
<Users className="h-5 w-5 text-primary" aria-hidden="true" /> Week{' '}
{overview.lineupRecommendation?.week ?? ''} lineup optimizer
</h2>
Run both workspace coverage gates from Husky and cover the lineup optimizer branches that brought backend coverage below the existing 80 percent threshold.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@sfreeman422
sfreeman422 merged commit 0c86e46 into master Sep 9, 2026
10 checks passed
@sfreeman422

Copy link
Copy Markdown
Collaborator Author

@copilot Fix the code for all comments in this review thread.

When a review comment includes a suggested change, apply the suggestion exactly.

Do not make changes beyond what is described in the linked review thread.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants