-
Notifications
You must be signed in to change notification settings - Fork 23
feat: implement time based attendance tracking #1051
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
| var minutesAttended *int | ||
|
|
||
| if checkIn == "" && checkOut == "" { | ||
| if attendance.AttendanceStatus == models.Present || attendance.AttendanceStatus == models.Partial { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If a record has attendance_status = 'partial' but no check-in/out times, System gives it full scheduled_minutes instead of 0.
corypride
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice implementation, it tests good, just a couple of small things and i think this is good to go.
- The "Time in Class" column shifts on Securebook Screen sizes.
- Maybe we should think about how frontend displays or handles this in-progress state. Say Waino was checked in at 7:00 PM and it's now later (say 8:30 PM), should the system be showing:
"In-progress for 1.5 hours"?
Or just show check-in time with empty check-out?
481d1b0 to
fe856c5
Compare
@corypride can you check this again on secure book screen size. I added keighan's changes to the code and changed things and made the screen real estate even more minimal. Please let me know. |
Good question, not sure what the answer is or how we approach this? i'm good with empty check-out for now and then come back to enhance for any changes? @CK-7vn what is your opinion? |
CK-7vn
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very trivial things, works great.
| } | ||
|
|
||
| func (srv *Server) handleGetAttendanceRateForEvent(w http.ResponseWriter, r *http.Request, log sLog) error { | ||
| eventID, err := strconv.Atoi(r.PathValue("class_id")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know you didn't change this, but...can you make the change while you're in here? eventID != class_id O.o
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good catch, i'll make the change all the way down the chain
| attendance.CheckOutAt = &checkOut | ||
| } | ||
|
|
||
| if minutesAttended != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can compact this if statement ot just attendance.MinutesAttended = minutesAttended
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changed to just attendance.MinutesAttended = minutesAttended ... nil is a possible value.
backend/src/database/programs.go
Outdated
| models.EnrollmentIncompleteTransfered, | ||
| } | ||
|
|
||
| csvRateCast := "COALESCE(pca.minutes_attended, pca.scheduled_minutes, 0)::numeric" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This ratio calculation is in 4 different functions unless i'm missing something, GetProgramsFacilitiesStats, GetProgramsFacilityStats, GetProgramsOverviewTable, and GetProgramsCSVData, is there anyway we can just extract it out into a function?
func buildPartialAttendanceRatioSQL(dialectName string) string {
castMinutes := "COALESCE(pcea.minutes_attended, pcea.scheduled_minutes, 0)::numeric"
if dialectName == "sqlite" {
castMinutes = "CAST(COALESCE(pcea.minutes_attended, pcea.scheduled_minutes, 0) AS REAL)"
}
ratioExpr := fmt.Sprintf("%s / NULLIF(COALESCE(pcea.scheduled_minutes, pcea.minutes_attended, 0), 0)", castMinutes)
return fmt.Sprintf("CASE WHEN %s < 1 THEN %s ELSE 1 END", ratioExpr, ratioExpr)
}There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good call, i'll consolidate the code




Description of the change
Implemented a time based attendance system that tracks actual attendance duration rather than presence/absence. This would allow administrators to record when residents arrive and leave classes. Ultimately this will provide more accurate attendance data for reporting and compliance purposes.
Screenshot(s)