Fix/raise confidence score#296
Conversation
📝 WalkthroughWalkthroughConfiguration defaults for data decay are reduced. Location processing SQL is enhanced to include ChangesData Decay Configuration and Routing Flow Refinements
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
There was a problem hiding this comment.
🧹 Nitpick comments (2)
src/test/java/com/p2ps/service/DataDecayServiceTest.java (1)
34-39: ⚡ Quick winAssert the new 3-day cutoff in this regression test.
This test was updated for the new penalty/floor, but it still accepts any
LocalDateTime, so it will pass even ifexecuteDataDecay()keeps using the old 14-day window. Please capture the cutoff argument and assert it is approximatelynow().minusDays(3).Proposed test change
+import org.mockito.ArgumentCaptor; + import java.time.LocalDateTime; @@ void shouldExecuteDataDecayAndCallRepositoryWithCorrectPenalty() { Double expectedPenalty = 0.1; Double expectedMinConfidenceFloor = 0.05; + LocalDateTime beforeCall = LocalDateTime.now(); when(repository.applyDecayToOldRecords(eq(expectedPenalty), any(LocalDateTime.class), eq(expectedMinConfidenceFloor))) .thenReturn(5); dataDecayService.executeDataDecay(); + LocalDateTime afterCall = LocalDateTime.now(); - verify(repository).applyDecayToOldRecords(eq(expectedPenalty), any(LocalDateTime.class), eq(expectedMinConfidenceFloor)); + ArgumentCaptor<LocalDateTime> cutoffCaptor = ArgumentCaptor.forClass(LocalDateTime.class); + verify(repository).applyDecayToOldRecords(eq(expectedPenalty), cutoffCaptor.capture(), eq(expectedMinConfidenceFloor)); + + LocalDateTime capturedCutoff = cutoffCaptor.getValue(); + LocalDateTime minExpected = beforeCall.minusDays(3); + LocalDateTime maxExpected = afterCall.minusDays(3); + org.junit.jupiter.api.Assertions.assertFalse(capturedCutoff.isBefore(minExpected)); + org.junit.jupiter.api.Assertions.assertFalse(capturedCutoff.isAfter(maxExpected)); }🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/test/java/com/p2ps/service/DataDecayServiceTest.java` around lines 34 - 39, The test currently stubs and verifies repository.applyDecayToOldRecords(eq(expectedPenalty), any(LocalDateTime.class), eq(expectedMinConfidenceFloor)) so it won't catch if executeDataDecay() still uses the old 14-day cutoff; change the test to capture the LocalDateTime argument passed to repository.applyDecayToOldRecords (use an ArgumentCaptor<LocalDateTime> or verify with an argThat) after calling dataDecayService.executeDataDecay(), then assert the captured cutoff is approximately Instant.now().minus(3, DAYS) (or LocalDateTime.now().minusDays(3)) within a small tolerance (e.g. a few seconds) while keeping the same checks for expectedPenalty and expectedMinConfidenceFloor.src/main/java/com/p2ps/service/RoutingService.java (1)
99-105: ⚡ Quick winExtract the
user_locremoval into a shared helper.This exact block is duplicated three times (eager here, lazy at Lines 144-147, and
RoutingAsyncServiceLines 72-75). Centralizing it onRoutingService(which the async service already resolves as a bean) keeps the invariant in one place.♻️ Suggested helper
/** Removes the leading user marker point (issue: redundant with blue ping). */ void stripUserPoint(List<RoutePoint> route) { if (!route.isEmpty() && "user_loc".equals(route.getFirst().getItemId())) { route.removeFirst(); } }🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/main/java/com/p2ps/service/RoutingService.java` around lines 99 - 105, Duplicate logic that removes the leading "user_loc" point appears in RoutingService (optimizedRoute) and RoutingAsyncService; extract it into a single helper on RoutingService named stripUserPoint(List<RoutePoint> route) that checks route.isEmpty() and compares route.getFirst().getItemId() to "user_loc" then removes the first element; replace the three inlined blocks (the one using optimizedRoute in RoutingService, the lazy block around Lines 144-147, and the one in RoutingAsyncService) with calls to RoutingService.stripUserPoint(...) so the invariant is centralized and both services use the same bean method.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@src/main/java/com/p2ps/service/RoutingService.java`:
- Around line 99-105: Duplicate logic that removes the leading "user_loc" point
appears in RoutingService (optimizedRoute) and RoutingAsyncService; extract it
into a single helper on RoutingService named stripUserPoint(List<RoutePoint>
route) that checks route.isEmpty() and compares route.getFirst().getItemId() to
"user_loc" then removes the first element; replace the three inlined blocks (the
one using optimizedRoute in RoutingService, the lazy block around Lines 144-147,
and the one in RoutingAsyncService) with calls to
RoutingService.stripUserPoint(...) so the invariant is centralized and both
services use the same bean method.
In `@src/test/java/com/p2ps/service/DataDecayServiceTest.java`:
- Around line 34-39: The test currently stubs and verifies
repository.applyDecayToOldRecords(eq(expectedPenalty), any(LocalDateTime.class),
eq(expectedMinConfidenceFloor)) so it won't catch if executeDataDecay() still
uses the old 14-day cutoff; change the test to capture the LocalDateTime
argument passed to repository.applyDecayToOldRecords (use an
ArgumentCaptor<LocalDateTime> or verify with an argThat) after calling
dataDecayService.executeDataDecay(), then assert the captured cutoff is
approximately Instant.now().minus(3, DAYS) (or LocalDateTime.now().minusDays(3))
within a small tolerance (e.g. a few seconds) while keeping the same checks for
expectedPenalty and expectedMinConfidenceFloor.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 94221905-3145-4143-85db-7aedb6a167d5
📒 Files selected for processing (9)
src/main/java/com/p2ps/service/DataDecayService.javasrc/main/java/com/p2ps/service/LocationProcessorWorker.javasrc/main/java/com/p2ps/service/RoutingAsyncService.javasrc/main/java/com/p2ps/service/RoutingService.javasrc/main/resources/application.propertiessrc/test/java/com/p2ps/controller/RoutingControllerTest.javasrc/test/java/com/p2ps/service/DataDecayServiceTest.javasrc/test/java/com/p2ps/service/LocationProcessorWorkerTest.javasrc/test/java/com/p2ps/service/RoutingServiceTest.java


maxed the default confidence score and removed the "tu" point from the in-door map
Summary by CodeRabbit
Release Notes