fix: resolve issue #1398 - Enable Checkout after Midnight for Shift Workers#1399
Conversation
|
Warning Review limit reached
More reviews will be available in 16 minutes and 58 seconds. Learn how PR review limits work. Your organization has run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Hi @sonusharma6-dsa, thanks for contributing to InternHack! 🎉 I have automatically:
Our workflows will now analyze your changes to classify:
Tip Ensure your PR description references the issue it resolves (e.g. Happy coding! 🚀 |
2316de7 to
3787533
Compare
3787533 to
1a3effd
Compare
Code Review — PR #1399: Enable checkout after midnight for shift workersHi @sonusharma6-dsa, the shift-worker use case is valid and the fix is correct. One edge case to verify. ✅ Core logic is correctReplacing: // Before: only finds today's check-in
prisma.attendanceRecord.findUnique({ where: { employeeId_date: { employeeId, date: today } } })With: // After: finds the most recent unchecked-out record regardless of date
prisma.attendanceRecord.findFirst({
where: { employeeId, checkOut: null },
orderBy: { date: "desc" },
})Using 🟡 Edge case: employee who never checked out from a previous dayWith the new query, an employee who checked in three days ago and never checked out (e.g. forgot to mark attendance) will have their checkout applied to that 3-day-old record instead of being told "no active check-in." This may or may not be desired behavior — document the intended policy. If you want to limit the look-back window, add a date floor: const cutoff = new Date();
cutoff.setDate(cutoff.getDate() - 2); // max 2 days look-back
prisma.attendanceRecord.findFirst({
where: { employeeId, checkOut: null, date: { gte: cutoff } },
orderBy: { date: "desc" },
})Otherwise, this is ready to merge. |
Thanks for suggestion |
27dcd58
into
Sachinchaurasiya360:main
Closes #1398