chore: build
Backend - Build & Lint / build (push) Successful in 31m59s
Frontend Admin - EAS Build / build (push) Successful in 1h32m56s

This commit is contained in:
Xor290
2026-11-01 13:08:58 +01:00
parent f3eaea4347
commit 0a18460f13
20 changed files with 1694 additions and 190 deletions
+73 -13
View File
@@ -511,7 +511,21 @@ func GetAllUsers(c *gin.Context) {
c.JSON(http.StatusForbidden, gin.H{"error": "Accès réservé aux livreurs et aux administrateurs"})
return
}
users, err := database.GetAllUsers()
limit := 100
offset := 0
if limitStr := c.Query("limit"); limitStr != "" {
if l, err := strconv.Atoi(limitStr); err == nil && l > 0 && l <= 100 {
limit = l
}
}
if offsetStr := c.Query("offset"); offsetStr != "" {
if o, err := strconv.Atoi(offsetStr); err == nil && o >= 0 {
offset = o
}
}
users, total, err := database.GetAllUsers(limit, offset)
if err != nil {
log.Printf("❌ [GET_ALL_USERS] Erreur: %v", err)
@@ -528,11 +542,12 @@ func GetAllUsers(c *gin.Context) {
})
}
log.Printf("✅ [GET_ALL_USERS] %d users récupérés", len(sanitized))
log.Printf("✅ [GET_ALL_USERS] %d users récupérés (offset=%d, total=%d)", len(sanitized), offset, total)
c.JSON(http.StatusOK, gin.H{
"users": sanitized,
"count": len(sanitized),
"users": sanitized,
"count": total,
"has_more": int64(offset+len(users)) < total,
})
}
@@ -549,13 +564,39 @@ func GetAllDeliveryMen(c *gin.Context) {
c.JSON(http.StatusInternalServerError, gin.H{"error": "Erreur récupération"})
return
}
usernames := make([]string, len(users))
for i, u := range users {
usernames[i] = u.Username
}
detailsByUsername := database.GetDeliveryPersonsDetailsBatch(usernames)
var sanitized []gin.H
for _, u := range users {
sanitized = append(sanitized, gin.H{
"id": u.ID,
"username": u.Username,
"role": u.Role,
})
det := detailsByUsername[u.Username]
if det == nil {
det = &db.DeliveryPersonDetails{Status: "offline"}
}
entry := gin.H{
"id": u.ID,
"username": u.Username,
"role": u.Role,
"status": det.Status,
"queue_size": det.QueueSize,
"total_deliveries": det.TotalDeliveries,
"completed_deliveries": det.CompletedDeliveries,
"pending_deliveries": det.PendingDeliveries,
}
if det.CurrentCommand != 0 {
entry["current_command"] = det.CurrentCommand
} else {
entry["current_command"] = nil
}
if det.HasLocation {
entry["location"] = gin.H{"latitude": det.Latitude, "longitude": det.Longitude}
} else {
entry["location"] = nil
}
sanitized = append(sanitized, entry)
}
log.Printf("✅ [GET_ALL_USERS] %d users récupérés", len(sanitized))
@@ -575,16 +616,33 @@ func GetAllClients(c *gin.Context) {
c.JSON(http.StatusForbidden, gin.H{"error": "Accès réservé aux livreurs et aux administrateurs"})
return
}
clients, err := database.GetAllClients()
limit := 100
offset := 0
if limitStr := c.Query("limit"); limitStr != "" {
if l, err := strconv.Atoi(limitStr); err == nil && l > 0 && l <= 100 {
limit = l
}
}
if offsetStr := c.Query("offset"); offsetStr != "" {
if o, err := strconv.Atoi(offsetStr); err == nil && o >= 0 {
offset = o
}
}
clients, total, err := database.GetAllClients(limit, offset)
if err != nil {
log.Printf("❌ [GET_ALL_CLIENTS] Erreur: %v", err)
c.JSON(http.StatusInternalServerError, gin.H{"error": "Erreur récupération"})
return
}
limited := rateLimitedClients(clients)
var sanitized []gin.H
for _, cl := range clients {
sanitized = append(sanitized, gin.H{
"rate_limited": limited[cl.Username],
"id": cl.ID,
"username": cl.Username,
"nom": cl.Nom,
@@ -596,14 +654,16 @@ func GetAllClients(c *gin.Context) {
"cancellations_count": cl.CancellationsCount,
"last_penalty_reason": cl.LastPenaltyReason,
"referral_balance": cl.ReferralBalance,
"parrain": cl.Parrain,
})
}
log.Printf("✅ [GET_ALL_CLIENTS] %d clients récupérés", len(sanitized))
log.Printf("✅ [GET_ALL_CLIENTS] %d clients récupérés (offset=%d, total=%d)", len(sanitized), offset, total)
c.JSON(http.StatusOK, gin.H{
"clients": sanitized,
"count": len(sanitized),
"clients": sanitized,
"count": total,
"has_more": int64(offset+len(clients)) < total,
})
}