fix: sql and redis request
Backend - Build & Lint / build (push) Failing after 19m3s

This commit is contained in:
2026-07-01 20:10:00 +02:00
parent 2311631825
commit 9e6473ed3f
3 changed files with 124 additions and 3 deletions
+16 -3
View File
@@ -40,14 +40,27 @@ func GetMyDeliveries(c *gin.Context) {
return
}
// Collecter tous les IDs et usernames en une passe pour éviter les N+1
commandIDs := make([]int, 0, len(commands))
clientUsernames := make([]string, 0, len(commands))
for _, cmd := range commands {
if cid, _ := strconv.Atoi(fmt.Sprintf("%v", cmd["id"])); cid > 0 {
commandIDs = append(commandIDs, cid)
}
if u, _ := cmd["username"].(string); u != "" {
clientUsernames = append(clientUsernames, u)
}
}
allItems, _ := database.GetCommandItemsBatch(commandIDs)
allClients, _ := database.GetClientsByUsernames(clientUsernames)
filteredCommands := make([]gin.H, len(commands))
for i, cmd := range commands {
commandID, _ := strconv.Atoi(fmt.Sprintf("%v", cmd["id"]))
items, _ := database.GetCommandItems(commandID)
items := allItems[commandID]
// Client info SANS téléphone
clientUsername, _ := cmd["username"].(string)
client, _ := database.GetClientByUsername(clientUsername)
client := allClients[clientUsername]
clientInfo := gin.H{"nom": "Client", "prenom": ""}
if client != nil {