Package com.nicholasalfonso.lato.service
Class DashboardService
java.lang.Object
com.nicholasalfonso.lato.service.DashboardService
Service that aggregates dashboard data and semester statistics for a user.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordAggregated dashboard payload for the home view.static final recordDashboard statistics exposed to API clients. -
Constructor Summary
ConstructorsConstructorDescriptionDashboardService(AssignmentRepository assignmentRepository, CourseRepository courseRepository, AssignmentMapper assignmentMapper) Creates the dashboard service with required repositories and mappers. -
Method Summary
Modifier and TypeMethodDescriptiondoubleCalculates overall semester completion percentage for the user.getDashboardData(User user) Builds the full dashboard payload for the given user.getIncompleteAssignments(User user) Returns incomplete, non-archived assignments sorted by due date.getStatistics(User user) Calculates dashboard statistics such as completion percentage and semester timing.groupAssignmentsByDate(List<AssignmentResponse> assignments) Groups assignment responses by due date while preserving insertion order.
-
Constructor Details
-
DashboardService
public DashboardService(AssignmentRepository assignmentRepository, CourseRepository courseRepository, AssignmentMapper assignmentMapper) Creates the dashboard service with required repositories and mappers.- Parameters:
assignmentRepository- repository for assignment queriescourseRepository- repository for course queriesassignmentMapper- mapper for assignment response DTOs
-
-
Method Details
-
getDashboardData
Builds the full dashboard payload for the given user.- Parameters:
user- the owning user- Returns:
- dashboard data including upcoming assignments, progress, grouping, and statistics
-
getIncompleteAssignments
Returns incomplete, non-archived assignments sorted by due date.- Parameters:
user- the owning user- Returns:
- incomplete assignment entities
-
calculateSemesterProgress
Calculates overall semester completion percentage for the user.- Parameters:
user- the owning user- Returns:
- percentage of completed non-archived assignments
-
groupAssignmentsByDate
public Map<LocalDate,List<AssignmentResponse>> groupAssignmentsByDate(List<AssignmentResponse> assignments) Groups assignment responses by due date while preserving insertion order.- Parameters:
assignments- assignment responses to group- Returns:
- map of due dates to assignment lists
-
getStatistics
Calculates dashboard statistics such as completion percentage and semester timing.- Parameters:
user- the owning user- Returns:
- dashboard statistics record
-