Skip to content

Fix one time habit retrospective rankings - #516

Merged
thomasluizon merged 2 commits into
mainfrom
fix/ticket-488-onetime-rank
Sep 9, 2026
Merged

Fix one time habit retrospective rankings#516
thomasluizon merged 2 commits into
mainfrom
fix/ticket-488-onetime-rank

Conversation

@thomasluizon

@thomasluizon thomasluizon commented Sep 9, 2026

Copy link
Copy Markdown
Owner

Closes #488

Summary

  • Exclude one time habit stats before ranking both top habits and needs attention.
  • Keep one time habits in the other retrospective totals while preventing them from occupying cadence based rankings.
  • Cover completed and incomplete one time competitors against an 86 percent recurring habit.

Assumptions

  • I strengthened the existing retrospective handler test because it already covered one time ranking behavior; I rejected creating a separate calculator test file for the same producer path.

Test evidence

  • Before changing code or tests, dotnet test tests\Orbit.Application.Tests\Orbit.Application.Tests.csproj --filter "FullyQualifiedName~GetRetrospectiveQueryHandlerTests.Handle_FlagsOneTimeTasks_AsBinary" passed 1 test with the defect present.
  • After strengthening the test but before fixing production code, dotnet test tests\Orbit.Application.Tests\Orbit.Application.Tests.csproj --no-restore --filter "FullyQualifiedName~GetRetrospectiveQueryHandlerTests.Handle_HabitRankings_ExcludeOneTimeTasks" failed as intended because TopHabits returned the completed one time task at 100 percent, the recurring habit at 86 percent, and the incomplete one time task at 0 percent.
  • After the production fix, the same strengthened test command passed 1 test.
  • dotnet build Orbit.slnx passed with 0 errors and 20 warnings from existing package constraints, analyzer compiler version mismatch, and deprecated Firebase token usage.
  • dotnet test passed all 6,162 tests.

@thomasluizon

Copy link
Copy Markdown
Owner Author

I will update src/Orbit.Application/Habits/Services/RetrospectiveMetricsCalculator.cs so both topHabits and needsAttention filter out stats whose habits have no cadence before ordering and taking their result limits. I will strengthen the existing calculator unit tests in their current test file with a completed one time task competing against a lower rate recurring habit, first recording the required passing and failing observations around the defect.

This belongs in the producer because filtering after Take(3) can discard one time entries without restoring the recurring candidates that were cut. I am not changing the client or weakening the label because neither alternative corrects ranking ownership or the returned data.

@pullfrog pullfrog Bot 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.

Important

The current head contains no implementation, so this PR does not yet change retrospective rankings.

Reviewed changes I reviewed the complete current head and checked the stated approach against the existing retrospective calculator and handler coverage.

  • Scaffold commit: 010d7c9 changes zero files and leaves production behavior unchanged.
  • Intended ranking fix: The proposed producer-side filter is correctly placed before ordering and Take(3), but it has not been committed.

⚠️ The ranking defect remains unchanged

The branch has no file delta from main, so RetrospectiveMetricsCalculator still includes one-time habits in both rankings and the existing test still expects that behavior. Merging this head cannot deliver the fix described by the PR.

Technical details
# Commit the retrospective ranking fix

## Affected sites
- `src/Orbit.Application/Habits/Services/RetrospectiveMetricsCalculator.cs:119` - `TopHabits` is still ranked from every generated stat.
- `src/Orbit.Application/Habits/Services/RetrospectiveMetricsCalculator.cs:125` - `NeedsAttention` is still ranked from every generated stat.
- `tests/Orbit.Application.Tests/Queries/Habits/GetRetrospectiveQueryHandlerTests.cs:329` - Existing coverage still asserts that a one-time task appears in `NeedsAttention`.

## Required outcome
- Exclude one-time stats before ordering and truncating both ranking lists.
- Add exact regression coverage proving a one-time task cannot displace a recurring ranking candidate.

Pullfrog  | Fix it ➔View workflow run | Using GPT Sol𝕏

@sonarqubecloud

sonarqubecloud Bot commented Sep 9, 2026

Copy link
Copy Markdown

@pullfrog pullfrog Bot 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.

✅ No new issues found.

Reviewed changes I reviewed the retrospective ranking implementation added since the prior Pullfrog review and its strengthened regression coverage.

  • Filtered recurring rankings: Reused a recurring stats sequence before ordering and Take(3) so one time habits cannot occupy either TopHabits or NeedsAttention.
  • Strengthened regression coverage: Replaced the previous binary flag assertion with exact ranking checks around completed and incomplete one time competitors and an 86 percent recurring habit.

Pullfrog  | View workflow run | Using GPT Sol𝕏

@thomasluizon
thomasluizon merged commit 98d08b5 into main Sep 9, 2026
26 checks passed
@thomasluizon
thomasluizon deleted the fix/ticket-488-onetime-rank branch September 9, 2026 19:28
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.

1 participant