v1.6.5: fix attendance unique constraint, schema sync, seed script
- Change attendance idx_attendance_user_date from unique to index (allow multiple shifts per day) - Reset migrations to single baseline init migration - Add seed script with admin user (admin/admin) - Update CLAUDE.md with migration workflow documentation - Various frontend fixes (queries, pages, hooks) Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -1381,7 +1381,7 @@ export async function punchAction(userId: number, data: PunchData) {
|
||||
const shiftMs = departureTime.getTime() - ongoing.arrival_time.getTime();
|
||||
const shiftHours = shiftMs / (1000 * 60 * 60);
|
||||
if (shiftHours > settings.break_threshold_hours) {
|
||||
const midpoint = new Date(ongoing.arrival_time.getTime() + shiftMs / 2);
|
||||
const midpoint = roundDown(new Date(ongoing.arrival_time.getTime() + shiftMs / 2), settings.clock_rounding_minutes);
|
||||
const breakMins =
|
||||
shiftHours > settings.break_threshold_hours * 2
|
||||
? settings.break_duration_long
|
||||
|
||||
@@ -102,7 +102,26 @@ export async function listOffers(params: ListOffersParams) {
|
||||
prisma.quotations.count({ where }),
|
||||
]);
|
||||
|
||||
const enriched = quotations.map(enrichQuotation);
|
||||
// Batch-fetch linked order statuses
|
||||
const orderIds = quotations
|
||||
.map((q) => q.order_id)
|
||||
.filter((id): id is number => id != null);
|
||||
const orderStatusMap = new Map<number, string>();
|
||||
if (orderIds.length > 0) {
|
||||
const orders = await prisma.orders.findMany({
|
||||
where: { id: { in: orderIds } },
|
||||
select: { id: true, status: true },
|
||||
});
|
||||
for (const o of orders) {
|
||||
orderStatusMap.set(o.id, o.status || "");
|
||||
}
|
||||
}
|
||||
|
||||
const enriched = quotations.map((q) => ({
|
||||
...enrichQuotation(q),
|
||||
order_status:
|
||||
q.order_id != null ? orderStatusMap.get(q.order_id) || null : null,
|
||||
}));
|
||||
|
||||
return { data: enriched, total, page, limit };
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user