Bug Fix Implementation Plan
Based on an investigation of the repository, here is the plan to resolve the three bugs you're seeing in production.
1. Stats Screen (Current & Longest Streak always 0)
Root Cause:
The StatsScreen tries to read data.userInfo?.currentStreak and data.summary?.summary?.longestStreak. However, the analytics endpoint (AnalyticsService.getUserStatistics()) currently hardcodes the streaks to 0. While currentStreak is already available from the gamification API (/api/v1/gamification/user-info), longestStreak is entirely missing from its response DTO.
Proposed Fix:
- Backend (
GamificationUserInfoResponse.java): Add an int longestStreak; field to the gamification user info DTO.
- Backend (
GamificationController.java): Map gamification.getLongestStreak() to the response in the getUserInfo endpoint.
- Frontend (
StatsScreen.tsx): Update the longest streak display to correctly read data.userInfo?.longestStreak instead of the hardcoded analytics placeholder.
2. Tasks Screen (0 images classified, 0% progress)
Root Cause:
In the tasks screen (UserMyTasksScreen.tsx), the progress calculation relies on the progress field embedded in TaskResponse.
However, in TaskService.java inside the backend, the methods fetching tasks for the user (getTasksForUser, getExploreTasksForUser, getTaskForUser) use a TaskMapper.toResponse(task, assignedToUser) overload that defaults to injecting a TaskProgressResponse.empty() object. This hardcodes both totalImages and imagesClassified to 0.
Proposed Fix:
- Backend (
TaskService.java): Update the getTasksForUser, getExploreTasksForUser, and getTaskForUser methods to explicitly call the mapper overload that builds progress via taskMapper.toResponse(task, isAssigned, buildProgress(task.getId())).
3. Seamless Batch Fetching (No endless images stream feeling)
Root Cause:
The swipe handler in SwipeScreen.tsx currently triggers fetchNextBatch only when the user exhausts the current batch (currentIndex + 1 >= dataBatch.length). This abruptly stops the flow and forces a loading screen (or requires clicking "Load More").
Proposed Fix:
- Frontend (
swipeStore.ts): Add an appendBatch: (items: any[]) => void function to Zustand to push new images onto the dataBatch array without resetting the user's current index.
- Frontend (
SwipeScreen.tsx): Implement a new fetchNextBatchInBackground function governed by a isFetchingNextBatch state flag to prevent duplicate network calls.
- Frontend (
SwipeScreen.tsx): In the handleSwipe function, check if the remaining cards fall below a threshold (dataBatch.length - (currentIndex + 1) <= 3). If so, trigger the background fetch asynchronously to fetch the next set of images seamlessly before the user runs out.
Bug Fix Implementation Plan
Based on an investigation of the repository, here is the plan to resolve the three bugs you're seeing in production.
1. Stats Screen (Current & Longest Streak always 0)
Root Cause:
The
StatsScreentries to readdata.userInfo?.currentStreakanddata.summary?.summary?.longestStreak. However, the analytics endpoint (AnalyticsService.getUserStatistics()) currently hardcodes the streaks to0. WhilecurrentStreakis already available from the gamification API (/api/v1/gamification/user-info),longestStreakis entirely missing from its response DTO.Proposed Fix:
GamificationUserInfoResponse.java): Add anint longestStreak;field to the gamification user info DTO.GamificationController.java): Mapgamification.getLongestStreak()to the response in thegetUserInfoendpoint.StatsScreen.tsx): Update the longest streak display to correctly readdata.userInfo?.longestStreakinstead of the hardcoded analytics placeholder.2. Tasks Screen (0 images classified, 0% progress)
Root Cause:
In the tasks screen (
UserMyTasksScreen.tsx), the progress calculation relies on theprogressfield embedded inTaskResponse.However, in
TaskService.javainside the backend, the methods fetching tasks for the user (getTasksForUser,getExploreTasksForUser,getTaskForUser) use aTaskMapper.toResponse(task, assignedToUser)overload that defaults to injecting aTaskProgressResponse.empty()object. This hardcodes bothtotalImagesandimagesClassifiedto 0.Proposed Fix:
TaskService.java): Update thegetTasksForUser,getExploreTasksForUser, andgetTaskForUsermethods to explicitly call the mapper overload that builds progress viataskMapper.toResponse(task, isAssigned, buildProgress(task.getId())).3. Seamless Batch Fetching (No endless images stream feeling)
Root Cause:
The swipe handler in
SwipeScreen.tsxcurrently triggersfetchNextBatchonly when the user exhausts the current batch (currentIndex + 1 >= dataBatch.length). This abruptly stops the flow and forces a loading screen (or requires clicking "Load More").Proposed Fix:
swipeStore.ts): Add anappendBatch: (items: any[]) => voidfunction to Zustand to push new images onto thedataBatcharray without resetting the user's current index.SwipeScreen.tsx): Implement a newfetchNextBatchInBackgroundfunction governed by aisFetchingNextBatchstate flag to prevent duplicate network calls.SwipeScreen.tsx): In thehandleSwipefunction, check if the remaining cards fall below a threshold (dataBatch.length - (currentIndex + 1) <= 3). If so, trigger the background fetch asynchronously to fetch the next set of images seamlessly before the user runs out.