8.0 KiB
Detailed Reports Page - Data Availability Analysis
Overview
This document analyzes what data is currently available in the backend and what information is missing for implementing the DetailedReports page.
1. Request Lifecycle Report
✅ Available Data:
-
Request Basic Info:
requestNumber(RE-REQ-2024-XXX)titlepriority(STANDARD/EXPRESS)status(DRAFT, PENDING, IN_PROGRESS, APPROVED, REJECTED, CLOSED)initiatorId→ Can get initiator name via User modelsubmissionDateclosureDatecreatedAt
-
Current Stage Info:
currentLevel(1-N)totalLevels- Can get current approver from
approval_levelstable
-
TAT Information:
totalTatHours(cumulative TAT)- Can calculate overall TAT from
submissionDatetoclosureDateorupdatedAt - Can get level-wise TAT from
approval_levels.tat_hours - Can get TAT compliance from
tat_alertstable
-
From Existing Services:
getCriticalRequests()- Returns requests with breach infogetUpcomingDeadlines()- Returns active level infogetRecentActivity()- Returns activity feed
❌ Missing Data:
-
Current Stage Name/Description:
- Need to join with
approval_levelsto getlevel_namefor current level - Currently only have
currentLevelnumber
- Need to join with
-
Overall TAT Calculation:
- Need API endpoint that calculates total time from submission to current/closure
- Currently have
totalTatHoursbut need actual elapsed time
-
TAT Compliance Status:
- Need to determine if "On Time" or "Delayed" based on TAT vs actual time
- Can calculate from
tat_alerts.is_breachedbut need endpoint
-
Timeline/History:
- Need endpoint to get all approval levels with their start/end times
- Need to show progression through levels
🔧 What Needs to be Built:
- New API Endpoint:
/dashboard/reports/lifecycle- Returns requests with:
- Full lifecycle timeline (all levels with dates)
- Overall TAT calculation
- TAT compliance status (On Time/Delayed)
- Current stage name
- All approvers in sequence
- Returns requests with:
2. User Activity Log Report
✅ Available Data:
-
Activity Model Fields:
activityIdrequestIduserId→ Can get user name from User modeluserName(stored directly)activityType(created, assignment, approval, rejection, etc.)activityDescription(details of action)ipAddress(available in model, but may not be logged)createdAt(timestamp)metadata(JSONB - can store additional info)
-
From Existing Services:
getRecentActivity()- Already returns activity feed with pagination- Returns:
activityId,requestId,requestNumber,requestTitle,type,action,details,userId,userName,timestamp,priority
❌ Missing Data:
-
IP Address:
- Field exists in model but may not be populated
- Need to ensure IP is captured when logging activities
-
User Agent/Device Info:
- Field exists (
userAgent) but may not be populated - Need to capture browser/device info
- Field exists (
-
Login Activities:
- Current activity model is request-focused
- Need separate user session/login tracking
- Can check
users.last_loginbut need detailed login history
-
Action Categorization:
- Need to map
activityTypeto display labels:- "created" → "Created Request"
- "approval" → "Approved Request"
- "rejection" → "Rejected Request"
- "comment" → "Added Comment"
- etc.
- Need to map
-
Request ID Display:
- Need to show request number when available
- Currently
getRecentActivity()returnsrequestNumber✅
🔧 What Needs to be Built:
-
Enhance Activity Logging:
- Capture IP address in activity service
- Capture user agent in activity service
- Add login activity tracking (separate from request activities)
-
New/Enhanced API Endpoint:
/dashboard/reports/activity-log- Filter by date range
- Filter by user
- Filter by action type
- Include IP address and user agent
- Better categorization of actions
3. Workflow Aging Report
✅ Available Data:
-
Request Basic Info:
requestNumbertitleinitiatorId→ Can get initiator nameprioritystatuscreatedAt(can calculate days open)submissionDate
-
Current Stage Info:
currentLeveltotalLevels- Can get current approver from
approval_levels
-
From Existing Services:
getUpcomingDeadlines()- Returns active requests with TAT info- Can filter by days open using
createdAtorsubmissionDate
❌ Missing Data:
-
Days Open Calculation:
- Need to calculate from
submissionDate(notcreatedAt) - Need to exclude weekends/holidays for accurate business days
- Need to calculate from
-
Start Date:
- Should use
submissionDate(when request was submitted, not created) - Currently have this field ✅
- Should use
-
Assigned To:
- Need current approver from
approval_levelswherelevel_number = current_level - Can get from
approval_levels.approver_name✅
- Need current approver from
-
Current Stage Name:
- Need
approval_levels.level_namefor current level - Currently only have level number
- Need
-
Aging Threshold Filtering:
- Need to filter requests where days open > threshold
- Need to calculate business days (excluding weekends/holidays)
🔧 What Needs to be Built:
- New API Endpoint:
/dashboard/reports/workflow-aging- Parameters:
threshold(days)dateRange(optional)page,limit(pagination)
- Returns:
- Requests with days open > threshold
- Business days calculation
- Current stage name
- Current approver
- Days open (business days)
- Parameters:
Summary
✅ Can Show Immediately:
-
Request Lifecycle Report (Partial):
- Request ID, Title, Priority, Status
- Initiator name
- Submission date
- Current level number
- Basic TAT info
-
User Activity Log (Partial):
- Timestamp, User, Action, Details
- Request ID (when applicable)
- Using existing
getRecentActivity()service
-
Workflow Aging (Partial):
- Request ID, Title, Initiator
- Days open (calendar days)
- Priority, Status
- Current approver (with join)
❌ Missing/Incomplete:
-
Request Lifecycle:
- Full timeline/history of all levels
- Current stage name (not just number)
- Overall TAT calculation
- TAT compliance status (On Time/Delayed)
-
User Activity Log:
- IP Address (field exists but may not be populated)
- User Agent (field exists but may not be populated)
- Login activities (separate tracking needed)
- Better action categorization
-
Workflow Aging:
- Business days calculation (excluding weekends/holidays)
- Current stage name
- Proper threshold filtering
🔧 Required Backend Work:
-
New Endpoints:
/dashboard/reports/lifecycle- Full lifecycle with timeline/dashboard/reports/activity-log- Enhanced activity log with filters/dashboard/reports/workflow-aging- Aging report with business days
-
Enhancements:
- Capture IP address in activity logging
- Capture user agent in activity logging
- Add login activity tracking
- Add business days calculation utility
- Add level name to approval levels response
-
Data Joins:
- Join
approval_levelsto get current stage name - Join
usersto get approver names - Join
tat_alertsto get breach/compliance info
- Join
Recommendations
Phase 1 (Quick Win - Use Existing Data):
- Implement basic reports using existing services
- Show available data (request info, basic activity, calendar days)
- Add placeholders for missing data
Phase 2 (Backend Development):
- Build new report endpoints
- Enhance activity logging to capture IP/user agent
- Add business days calculation
- Add level name to responses
Phase 3 (Full Implementation):
- Complete all three reports with full data
- Add filtering, sorting, export functionality
- Add date range filters
- Add user/role-based filtering