Appearance
Type Deep Dive — Direct Schedule Upsert And Import
1. WorkingSchedule đang ghi thẳng time_slot_user
Page WorkingScheduleCreate submit mutation upsertTimeSlotUser:
- trước tiên
delete_time_slot_usertrong khoảng_gte/_ltechouserIds, - sau đó
insert_time_slot_uservớion_conflictupdatestart_time,end_time.
Nếu edit theo ngày:
- range delete chỉ nằm ở ngày đó,
- nếu create theo tuần:
- range delete bao trọn tuần hiện tại của user đó.
Kết luận: đây là direct schedule write model, không hề qua request approval.
2. Form semantics
WorkingScheduleForm:
- build working dates theo weekday của tuần,
- map từ template id sang start/end/break/workday,
- cho phép cả template-based slot và manual slot,
- validate tối thiểu là phải có ít nhất một ca.
Form cũng đọc time_slot_user.requests(status = approved) để hiển thị change-shift semantics khi format slot.
3. Import semantics
WorkingScheduleImport + useWorkingScheduleImport:
- đọc Excel mẫu tuần hiện tại hoặc tuần sau,
- map mã ca sang
time_slot_template, - map user theo email nội bộ
@diva.vn, - build list
Time_Slot_User_Insert_Input, - gọi cùng mutation
UpsertTimeSlotUserDocument.
Quan trọng nhất: import là destructive overwrite theo tuần cho danh sách user trong file. Nó không merge từng ô.
4. Export semantics
WorkingSchedule export:
- load tất cả
time_slot_usertrong tuần, - group theo user,
- map tên ca sang template id,
- ghi Excel với 7 cột ngày trong tuần.
Đây là export từ source time_slot_user, không cộng overlay request chưa/đã duyệt theo logic timesheet.
5. Filter/User scope
Page WorkingSchedule xác định tập user bằng cách trộn:
- department users,
- branch users,
- CRM displayed accounts khi chạy platform CRM,
- shift group filters,
- disabled users chỉ bị loại nếu disable date nằm trước period đang xem.
Điều này làm schedule page thiên về operational planning surface hơn là request-tracking surface.
6. Findings kỹ thuật
| ID | Mức | Finding |
|---|---|---|
| S-01 | P0 | Import và create/edit cùng dùng upsertTimeSlotUser, tức toàn bộ schedule planning path hiện bypass approval engine. |
| S-02 | P0 | Mutation import xóa slot cũ trong tuần của user trước khi insert lại, nên file thiếu dữ liệu sẽ gây mất lịch chứ không chỉ "không import đủ". |
| S-03 | P1 | UI WorkingSchedule vẫn hiển thị approved requests gắn vào slot gốc, tạo cảm giác request flow và direct schedule flow là một, trong khi write paths thực tế tách đôi. |
| S-04 | P1 | Scope user phụ thuộc cả branch, department và CRM account filters; vì vậy chênh lệch platform/role có thể làm 2 người nhìn cùng một tuần nhưng thấy tập nhân sự khác nhau. |