update son the admincontroller acoording datas and update the md file as well

This commit is contained in:
2026-09-11 11:48:06 +05:30
parent 17bd316e4d
commit e8f4c0a593
2 changed files with 40 additions and 2 deletions

View File

@@ -2116,8 +2116,26 @@ func GetAdminBookings(c *fiber.Ctx) error {
return utils.Internal(c, "failed to count bookings")
}
// Newest first, and deterministically so.
//
// Without an ORDER BY the row order is unspecified — Postgres returns heap
// order, which in practice is oldest first. Two things follow, and both bit:
//
// 1. The newest booking sits on the LAST page. The console drains a
// bounded window, so once pickupbookings outgrows that window a
// just-created customer-app booking can never reach the Orders page at
// all. It is written correctly and is simply never fetched.
// 2. OFFSET pagination over an unordered result is not stable: the same
// page can return different rows across two requests, so draining pages
// can duplicate and skip rows well before that threshold.
//
// bookingid rather than createdat: it is the primary key and unique, so the
// sort needs no tiebreaker and the paging cannot wobble between equal
// timestamps. It also matches the order the console already sorts into
// client-side, so page 1 is the newest page by both definitions.
var bookings []models.PickupBooking
if err := query.Preload("Parcels").Preload("ServiceOptions").
Order("bookingid DESC").
Offset(offset).Limit(pagesize).Find(&bookings).Error; err != nil {
return utils.Internal(c, "failed to fetch bookings")
}