perf: nettoyage code mort, sécurisation clé, et remplacement des prints
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:em2rp/models/event_model.dart';
|
||||
import 'package:em2rp/models/equipment_model.dart';
|
||||
import 'package:em2rp/models/container_model.dart';
|
||||
@@ -84,7 +85,7 @@ class EventAvailabilityService {
|
||||
final conflicts = <AvailabilityConflict>[];
|
||||
|
||||
try {
|
||||
print('[EventAvailabilityService] Checking availability for equipment $equipmentId ($equipmentName)');
|
||||
if (kDebugMode) debugPrint('[EventAvailabilityService] Checking availability for equipment $equipmentId ($equipmentName)');
|
||||
|
||||
// Utiliser la Cloud Function pour vérifier la disponibilité
|
||||
final result = await _dataService.checkEquipmentAvailability(
|
||||
@@ -94,14 +95,14 @@ class EventAvailabilityService {
|
||||
excludeEventId: excludeEventId,
|
||||
);
|
||||
|
||||
print('[EventAvailabilityService] Result for $equipmentId: $result');
|
||||
if (kDebugMode) debugPrint('[EventAvailabilityService] Result for $equipmentId: $result');
|
||||
|
||||
final available = result['available'] as bool? ?? true;
|
||||
print('[EventAvailabilityService] Equipment $equipmentId available: $available');
|
||||
if (kDebugMode) debugPrint('[EventAvailabilityService] Equipment $equipmentId available: $available');
|
||||
|
||||
if (!available) {
|
||||
final conflictsData = result['conflicts'] as List<dynamic>? ?? [];
|
||||
print('[EventAvailabilityService] Found ${conflictsData.length} conflicts for equipment $equipmentId');
|
||||
if (kDebugMode) debugPrint('[EventAvailabilityService] Found ${conflictsData.length} conflicts for equipment $equipmentId');
|
||||
|
||||
for (final conflictData in conflictsData) {
|
||||
final conflict = conflictData as Map<String, dynamic>;
|
||||
@@ -119,19 +120,19 @@ class EventAvailabilityService {
|
||||
conflictingEvent: event,
|
||||
overlapDays: conflict['overlapDays'] as int? ?? 0,
|
||||
));
|
||||
print('[EventAvailabilityService] Added conflict with event ${event.name}');
|
||||
if (kDebugMode) debugPrint('[EventAvailabilityService] Added conflict with event ${event.name}');
|
||||
} catch (e) {
|
||||
print('[EventAvailabilityService] Error creating EventModel: $e');
|
||||
print('[EventAvailabilityService] EventData: $eventData');
|
||||
if (kDebugMode) debugPrint('[EventAvailabilityService] Error creating EventModel: $e');
|
||||
if (kDebugMode) debugPrint('[EventAvailabilityService] EventData: $eventData');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
print('[EventAvailabilityService] Error checking availability: $e');
|
||||
if (kDebugMode) debugPrint('[EventAvailabilityService] Error checking availability: $e');
|
||||
}
|
||||
|
||||
print('[EventAvailabilityService] Returning ${conflicts.length} conflicts for equipment $equipmentId');
|
||||
if (kDebugMode) debugPrint('[EventAvailabilityService] Returning ${conflicts.length} conflicts for equipment $equipmentId');
|
||||
return conflicts;
|
||||
}
|
||||
|
||||
@@ -234,11 +235,11 @@ class EventAvailabilityService {
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
print('[EventAvailabilityService] Error processing event $eventId for quantity: $e');
|
||||
if (kDebugMode) debugPrint('[EventAvailabilityService] Error processing event $eventId for quantity: $e');
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
print('[EventAvailabilityService] Error getting available quantity: $e');
|
||||
if (kDebugMode) debugPrint('[EventAvailabilityService] Error getting available quantity: $e');
|
||||
}
|
||||
|
||||
return totalQuantity - reservedQuantity;
|
||||
@@ -298,7 +299,7 @@ class EventAvailabilityService {
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
print('[EventAvailabilityService] Error processing event $eventId: $e');
|
||||
if (kDebugMode) debugPrint('[EventAvailabilityService] Error processing event $eventId: $e');
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -361,7 +362,7 @@ class EventAvailabilityService {
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
print('[EventAvailabilityService] Error processing event $eventId: $e');
|
||||
if (kDebugMode) debugPrint('[EventAvailabilityService] Error processing event $eventId: $e');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user