Analytics & Dashboards
Relevant source files
The following files were used as context for generating this wiki page:
- src/main/java/com/example/demo/controllers/AnalyticsController.java
- src/main/java/com/example/demo/services/AnalyticsService.java
- src/main/java/com/example/demo/dto/response/AnalyticsResponse.java
- src/main/java/com/example/demo/services/TaskService.java
- README.md
- src/main/resources/templates/kanban.html
- src/main/resources/static/js/task-detail.js
Introduction
The Analytics & Dashboards system in the DTM (Dashboard Task Management) application provides real-time insights into team productivity, project progress, and task distribution. It is designed to assist administrators and managers in monitoring key performance indicators (KPIs) such as task completion ratios, overdue items, and individual employee performance.
The system operates by aggregating data from tasks, historical changes, and user assignments. While high-level analytics are reserved for users with ADMIN and MANAGER roles, specific features like task history are accessible to all project participants to maintain transparency.
Sources: README.md:154-156, src/main/java/com/example/demo/controllers/AnalyticsController.java:37-40
Analytics Architecture
The analytics module follows a standard Controller-Service-Repository pattern. Data is processed primarily through the AnalyticsService, which applies role-based filters to ensure users only see data they are authorized to access.
Data Flow for Performance Metrics
The following diagram illustrates how the system aggregates task data to generate performance reports for employees.
This diagram shows the role-based data retrieval flow for generating analytics reports.
Sources: src/main/java/com/example/demo/services/AnalyticsService.java:35-50, src/main/java/com/example/demo/controllers/AnalyticsController.java:23-44
Key Analytics Components
1. Task Statistics
The system tracks task distribution across two primary dimensions: Status and Priority. This allows managers to identify bottlenecks in the IN_PROGRESS or ON_REVIEW stages.
| Metric | Grouping Criteria | Purpose |
|---|---|---|
| Tasks by Status | NEW, IN_PROGRESS, ON_REVIEW, DONE | Identifying workflow bottlenecks |
| Tasks by Priority | LOW, MEDIUM, HIGH | Monitoring high-risk/urgent deliverables |
| Completion Ratio | Completed vs. Overdue | Assessing overall project health |
Sources: src/main/java/com/example/demo/dto/response/AnalyticsResponse.java:11-17, README.md:162-167
2. Employee Performance Tracking
Employee performance is calculated dynamically based on the current state of assigned tasks. The AnalyticsService calculates several metrics for each user:
- Total Assigned: Total count of tasks where the user is an assignee.
- Completed: Tasks moved to the
DONEstatus. - Overdue: Tasks where the
dueDatehas passed and the status is notDONE. - In Progress: Active tasks currently in the
IN_PROGRESSstate.
Sources: src/main/java/com/example/demo/services/AnalyticsService.java:160-185, README.md:169-175
3. Task History and Audit Trail
Every modification to a task (status changes, priority updates, assignee shifts) is recorded in a history log. This provides a transparent audit trail accessible via the task detail view.
Sequence of events for retrieving the audit trail of a specific task.
Sources: src/main/java/com/example/demo/controllers/AnalyticsController.java:85-94, src/main/java/com/example/demo/services/AnalyticsService.java:101-115
API Endpoints
The AnalyticsController exposes the following REST endpoints for data consumption. All endpoints require Bearer Token authentication.
| Endpoint | Method | Access | Parameters |
|---|---|---|---|
/api/analytics | GET | ADMIN, MANAGER | projectId, departmentId |
/api/analytics/tasks/by-status | GET | ADMIN, MANAGER | projectId |
/api/analytics/tasks/by-priority | GET | ADMIN, MANAGER | projectId |
/api/analytics/employees/performance | GET | ADMIN, MANAGER | departmentId |
/api/analytics/tasks/{taskId}/history | GET | ALL PARTICIPANTS | taskId |
Sources: src/main/java/com/example/demo/controllers/AnalyticsController.java:31-95
Implementation Details
Role-Based Data Filtering
Data visibility is strictly controlled within the service layer. ADMIN users can view data across all departments, whereas MANAGER users are restricted to the department they manage.
// src/main/java/com/example/demo/services/AnalyticsService.java:122-137
if (user.getRole() == Role.ADMIN) {
all = projectId != null
? taskRepository.findByProjectId(projectId)
: taskRepository.findAll();
} else if (user.getRole() == Role.MANAGER) {
Department dept = departmentRepository.findByManagerId(user.getId())
.orElseThrow(() -> new AccessDeniedException(
"У руководителя нет назначенного отдела"));
all = taskRepository.findByDepartmentId(dept.getId());
}
Overdue Logic
A task is considered overdue if the current date is past the dueDate and the status is not DONE. This calculation is performed in real-time during analytics generation.
Sources: src/main/java/com/example/demo/services/AnalyticsService.java:176-180, src/main/java/com/example/demo/services/TaskService.java:547-560
Visual Dashboards (Kanban & Progress)
While backend analytics provide raw data, the frontend utilizes this for visual representation:
- Kanban Board: Uses task counts per status to populate column headers.
- Task Detail Progress: Calculates the percentage of completed subtasks for individual task monitoring.
Sources: src/main/resources/templates/kanban.html:56-61, src/main/resources/static/js/task-detail.js:41-48
Conclusion
The Analytics & Dashboards module is a critical component for management oversight within DTM. By combining real-time task status tracking with historical audit trails and employee performance metrics, it provides a comprehensive view of organizational productivity while maintaining strict role-based access controls.