Skip to content

Feat/#86 retrieve selections#118

Merged
PhilipWoulfe merged 8 commits intomainfrom
feat/#86-retrieve-selections
Mar 12, 2026
Merged

Feat/#86 retrieve selections#118
PhilipWoulfe merged 8 commits intomainfrom
feat/#86-retrieve-selections

Conversation

@PhilipWoulfe
Copy link
Copy Markdown
Owner

No description provided.

… on Australia selection page with full API/UI tests

add development-only mock data toggle for current selections endpoint and document env config
… mapping, and persist dev mock selections in memory
…normalize legacy selection data while keeping compatibility

remove legacy selection data
Copilot AI review requested due to automatic review settings March 12, 2026 09:47
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Implements “current selections” retrieval and ordered driver selection support end-to-end (API → service/repo → web UI), plus a Development-mode in-memory mock to validate the UI without Cosmos data.

Changes:

  • Added GET /selections/current plus service/repository support to return a “current selections snapshot” (CurrentSelectionDto).
  • Switched selection payloads/storage to ordered selections (OrderedSelections with { Position, DriverId }) and updated UI to populate controls from the snapshot.
  • Added Development toggle (DevSettings:MockCurrentSelections) to use in-memory mock selection state for GET/PUT selection endpoints.

Reviewed changes

Copilot reviewed 19 out of 19 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
src/F1.Web/Pages/AustraliaSelection.razor Loads /selections/current to populate UI controls; sends ordered selections on save.
src/F1.Web/Models/Selection.cs Adds OrderedSelections and SelectionPosition (keeps legacy Selections list).
src/F1.Web/Models/CurrentSelectionItem.cs Adds client model for /selections/current response.
src/F1.Api/Controllers/SelectionsController.cs Adds GET /selections/current and Development mock behavior for selection endpoints.
src/F1.Api/appsettings.Development.json Enables DevSettings:MockCurrentSelections by default in Development.
src/F1.Services/SelectionService.cs Adds GetCurrentSelectionsAsync, switches validation/upsert to ordered selections.
src/F1.Infrastructure/Repositories/CosmosSelectionRepository.cs Updates query to ORDER BY c._ts DESC (but also changes field casing).
src/F1.Core/Interfaces/ISelectionService.cs Adds GetCurrentSelectionsAsync.
src/F1.Core/Models/Selection.cs Replaces flat Selections with OrderedSelections.
src/F1.Core/Dtos/SelectionSubmissionDto.cs Switches submission DTO to OrderedSelections.
src/F1.Core/Dtos/CurrentSelectionDto.cs Adds DTO for snapshot rows.
tests/F1.Web.Tests/AustraliaSelectionTests.cs Updates/enhances UI tests to account for /selections/current and ordered selection behavior.
tests/F1.Api.Tests/SelectionServiceTests.cs Updates unit tests for ordered submissions and adds coverage for GetCurrentSelectionsAsync.
tests/F1.Api.Tests/Integration/CurrentSelectionsEndpointTests.cs Adds integration test for /selections/current.
tests/F1.Api.Tests/Integration/CosmosSelectionRepositoryTests.cs Updates repository test data for ordered selections and asserts query text.
tests/F1.Api.Tests/Controllers/SelectionsControllerTests.cs Adds controller tests for GetCurrent and Development mock behavior.
docker-compose.yml / README.md / .env.example Documents and wires env var DEV_MOCK_CURRENT_SELECTIONS for Development mock mode.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/F1.Core/Dtos/SelectionSubmissionDto.cs
Comment thread src/F1.Services/SelectionService.cs Outdated
Comment thread src/F1.Services/SelectionService.cs
Comment thread src/F1.Services/SelectionService.cs Outdated
Comment thread src/F1.Infrastructure/Repositories/CosmosSelectionRepository.cs Outdated
Comment thread src/F1.Core/Models/Selection.cs
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 12, 2026

@PhilipWoulfe I've opened a new pull request, #119, to work on those changes. Once the pull request is ready, I'll request review from you.

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 12, 2026

@PhilipWoulfe I've opened a new pull request, #120, to work on those changes. Once the pull request is ready, I'll request review from you.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 19 out of 19 changed files in this pull request and generated 4 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/F1.Services/SelectionService.cs Outdated
Comment thread tests/F1.Web.Tests/AustraliaSelectionTests.cs
Comment thread src/F1.Services/SelectionService.cs Outdated
Comment thread src/F1.Api/Controllers/SelectionsController.cs
Copilot AI and others added 2 commits March 12, 2026 10:17
`ValidateSelections` only checked that 5 non-empty drivers were present,
allowing payloads with extra empty/whitespace entries (e.g. 6 items: 5
valid + 1 empty) to pass validation and be persisted as-is —
inconsistent with `ValidateMockSubmission` which requires `Count == 5`.

## Changes

- **`SelectionService.ValidateSelections`**: Added upfront
`selections.Count != 5` guard before the existing non-empty/distinct
checks:

```csharp
if (selections.Count != 5)
{
    throw new SelectionValidationException("Exactly 5 unique drivers must be selected.");
}
```

- **`SelectionServiceTests`**: Added
`UpsertSelectionAsync_ShouldReject_WhenMoreThanFiveSelectionsSubmitted`
covering the 5-valid + 1-empty payload case.

<!-- START COPILOT CODING AGENT TIPS -->
---

💬 We'd love your input! Share your thoughts on Copilot coding agent in
our [2 minute survey](https://gh.io/copilot-coding-agent-survey).

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: PhilipWoulfe <8867626+PhilipWoulfe@users.noreply.github.com>
`GetCurrentSelectionsAsync` iterated `OrderedSelections` in persistence
order, making the endpoint non-deterministic and inconsistent with the
`Position` field's semantics.

## Changes

- **`SelectionService.cs`** — Sort `OrderedSelections` by `Position`
before building response rows:
  ```csharp
  var orderedSelections = selection.OrderedSelections
      .OrderBy(item => item.Position)
      .ToList();
  ```
- **`SelectionServiceTests.cs`** — Added
`GetCurrentSelectionsAsync_ShouldReturnRowsSortedByPosition_WhenSelectionsAreOutOfOrder`
to assert correct ordering when items are persisted out of sequence.

<!-- START COPILOT CODING AGENT TIPS -->
---

✨ Let Copilot coding agent [set things up for
you](https://github.com/PhilipWoulfe/F1Competition/issues/new?title=✨+Set+up+Copilot+instructions&body=Configure%20instructions%20for%20this%20repository%20as%20documented%20in%20%5BBest%20practices%20for%20Copilot%20coding%20agent%20in%20your%20repository%5D%28https://gh.io/copilot-coding-agent-tips%29%2E%0A%0A%3COnboard%20this%20repo%3E&assignees=copilot)
— coding agent works faster and does higher quality work when set up for
your repo.

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: PhilipWoulfe <8867626+PhilipWoulfe@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 12, 2026

@PhilipWoulfe I've opened a new pull request, #121, to work on those changes. Once the pull request is ready, I'll request review from you.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 19 out of 19 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/F1.Api/Controllers/SelectionsController.cs
Comment thread src/F1.Services/SelectionService.cs Outdated
Comment thread tests/F1.Api.Tests/Integration/CosmosSelectionRepositoryTests.cs Outdated
@PhilipWoulfe PhilipWoulfe merged commit f920b14 into main Mar 12, 2026
6 checks passed
@PhilipWoulfe PhilipWoulfe deleted the feat/#86-retrieve-selections branch March 12, 2026 11:06
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.

3 participants