chore: refacto

This commit is contained in:
2026-03-27 22:23:46 +01:00
parent 75bf4caaa1
commit 5380abe8ed
67 changed files with 1751 additions and 2573 deletions
+4 -9
View File
@@ -126,18 +126,13 @@ func tryAssignCommandWithPriority(
Longitude: location.Longitude,
}
// 2. Récupérer livreurs actifs
activeLivreurs, err := database.GetAllActiveDeliveryPersons()
if err != nil || len(activeLivreurs) == 0 {
log.Printf("⚠️ [CRON] Cmd %d - Aucun livreur disponible", commandID)
// 2. Récupérer livreurs éligibles (selon le mode single/category_based)
usernames, err := database.GetEligibleDeliverymenForCommand(commandID)
if err != nil || len(usernames) == 0 {
log.Printf("⚠️ [CRON] Cmd %d - Aucun livreur éligible disponible", commandID)
return false
}
usernames := make([]string, len(activeLivreurs))
for i, livreur := range activeLivreurs {
usernames[i] = livreur.Username
}
// 3. Trouver le plus proche
nearest, err := geoService.FindNearestDeliveryPersonFast(targetCoords, usernames)
if err != nil {
+2 -1
View File
@@ -148,7 +148,8 @@ func PointsSyncWorker(database *db.Database) {
}
// Mettre à jour dans la DB principale
err = database.AddClientPoints(username, points)
pool := "pool_0"
err = database.AddClientPointsByCategory(username, points, pool)
if err != nil {
log.Printf("⚠️ Erreur sync points pour %s: %v", username, err)
continue