chore: refacto
This commit is contained in:
@@ -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 {
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user