5.0 KiB
5.0 KiB
Sprint 6 Phase 4 Dashboard Review
1. Summary
ปรับปรุง Dashboard ทั้งฝั่ง Employee และ HRD บนโมดูล overview เดิม โดยเพิ่ม KPI cards, filter, chart sections, K/S/A progress, recent activity และย้ายการคำนวณหลักไปใช้ database aggregation เพื่อลดการโหลดข้อมูลดิบเข้าหน่วยความจำ
2. Files Changed
src/app/dashboard/overview/layout.tsxsrc/app/dashboard/overview/page.tsxsrc/app/dashboard/overview/@area_stats/page.tsxsrc/app/dashboard/overview/@bar_stats/page.tsxsrc/app/dashboard/overview/@pie_stats/page.tsxsrc/app/dashboard/overview/@sales/page.tsxsrc/features/overview/server/overview-data.tssrc/features/overview/components/overview-filter-panel.tsxsrc/features/overview/components/ksa-progress.tsxsrc/features/overview/components/top-courses-chart.tsxsrc/features/overview/components/area-graph.tsxsrc/features/overview/components/bar-graph.tsxsrc/features/overview/components/pie-graph.tsx
3. Database Queries Added
- Aggregate KPI query by approval status
- Aggregate K/S/A approved hours by category
- Monthly approved-hours and approved-record trend by month
- Department ranking by approved hours
- Top courses by approved hours
- Active employee scope query with company/department filters
- Passed / not-passed target calculation from per-user yearly approved hours
- Pending review count query
- Distinct filter option queries for year, company, department
- Recent activity query with
limit 5
4. KPI Cards Added
Employee
- Approved Hours
- Pending Hours
- Rejected Hours
- Completion Percentage
HRD
- Total Employees
- Employees Passed Target
- Employees Not Passed Target
- Pending Review Count
5. Charts Added
Employee
- K/S/A Progress section
- Recent Activity section
HRD
- K/S/A Distribution
- Monthly Training Trend
- Department Ranking
- Top Courses
6. Filters Added
Employee
- Year
HRD
- Year
- Company
- Department
7. Responsive Notes
- Filter panel ใช้ grid ที่ยุบลงได้บน mobile/tablet
- KPI cards แสดง 1 คอลัมน์บนจอแคบ และขยายเป็น 2/4 คอลัมน์ตาม breakpoint
- Employee dashboard ใช้ 2 sections หลักที่ไม่บีบข้อความจนอ่านยากบน 360px - 412px
- HRD charts ถูกจัดใน grid เดิมของ overview และยังคงรองรับ 768px, 1024px, 1440px
8. Performance Notes
- ใช้ SQL aggregation สำหรับ KPI และ charts แทนการโหลด training records ทั้งหมดมา reduce ใน memory
- Recent activity จำกัดที่ 5 รายการ
- Ranking charts จำกัดที่ top 5
- Filter options ดึงจาก query ที่ group/distinct ตาม organization
- ใช้
cache()เพื่อให้ layout และ parallel routes ใช้ dataset ชุดเดียวกันใน request เดียว
9. Manual Test Checklist
- Employee เปิด
/dashboard/overviewแล้วเห็น KPI 4 ใบ - Employee เปลี่ยนปีแล้ว KPI, K/S/A progress และ recent activity เปลี่ยนตาม
- HRD เปิด
/dashboard/overviewแล้วเห็น KPI 4 ใบและ chart 4 ส่วน - HRD กรองตามปี / บริษัท / แผนก แล้ว KPI และ chart เปลี่ยนตาม
- HRD ดู Pending Review Count ได้ถูกต้อง
- Recent Activity แสดงสถานะรายการอบรมถูกต้อง
- Dashboard ใช้งานได้บน 360px, 390px, 412px, 768px, 1024px, 1440px
10. Known Limitations
- การกรอง HRD ตาม company/department ยังอิงข้อมูลบน
usersปัจจุบัน ไม่ใช่ historical snapshot ตอน submit record - Top Courses และ Department Ranking ใช้ approved hours เป็นตัวจัดอันดับหลัก
- หากปีที่เลือกไม่มี training policy ระบบจะ fallback ไป policy ล่าสุด หรือ 0 ชั่วโมงเมื่อไม่มี policy เลย
11. Go-Live Readiness Score
8.5 / 10
เหตุผล:
- ฟังก์ชันหลักครบตาม requirement
- ไม่มี schema change และไม่ต้อง migrate
- typecheck ผ่าน
- lint ผ่าน โดยเหลือเฉพาะ warning เดิมของโปรเจกต์ที่ไม่เกี่ยวกับ phase นี้
- ยังควรมี manual QA ฝั่ง responsive และตรวจค่าจริงกับ dataset production-like ก่อน go-live