feat: Add TripImageService for automatic trip image management
- Implemented TripImageService to load missing images for trips, reload images, and clean up unused images. - Added functionality to get image statistics and clean up duplicate images. - Created utility scripts for manual image cleanup and diagnostics in Firebase Storage. - Introduced tests for image loading optimization and photo quality algorithms. - Updated dependencies in pubspec.yaml and pubspec.lock for image handling.
This commit is contained in:
62
scripts/cleanup_images.dart
Normal file
62
scripts/cleanup_images.dart
Normal file
@@ -0,0 +1,62 @@
|
||||
import 'dart:io';
|
||||
import '../lib/services/trip_image_service.dart';
|
||||
|
||||
/// Script utilitaire pour nettoyer les images inutilisées
|
||||
/// À exécuter manuellement si nécessaire
|
||||
void main() async {
|
||||
print('🧹 Script de nettoyage des images inutilisées');
|
||||
print('=====================================');
|
||||
|
||||
try {
|
||||
final tripImageService = TripImageService();
|
||||
|
||||
// Remplacez par votre ID utilisateur
|
||||
// Vous pouvez le récupérer depuis Firebase Auth dans votre app
|
||||
const userId = 'YOUR_USER_ID_HERE';
|
||||
|
||||
if (userId == 'YOUR_USER_ID_HERE') {
|
||||
print('❌ Veuillez configurer votre userId dans le script');
|
||||
print(' Récupérez votre ID depuis Firebase Auth dans l\'app');
|
||||
return;
|
||||
}
|
||||
|
||||
print('📊 Récupération des statistiques...');
|
||||
final stats = await tripImageService.getImageStatistics(userId);
|
||||
|
||||
print('Statistiques actuelles:');
|
||||
print('- Voyages totaux: ${stats['totalTrips']}');
|
||||
print('- Voyages avec image: ${stats['tripsWithImages']}');
|
||||
print('- Voyages sans image: ${stats['tripsWithoutImages']}');
|
||||
|
||||
if (stats['tripsWithImages'] > 0) {
|
||||
print('\n🧹 Nettoyage des images inutilisées...');
|
||||
await tripImageService.cleanupUnusedImages(userId);
|
||||
|
||||
print('\n📊 Nouvelles statistiques...');
|
||||
final newStats = await tripImageService.getImageStatistics(userId);
|
||||
print('- Voyages totaux: ${newStats['totalTrips']}');
|
||||
print('- Voyages avec image: ${newStats['tripsWithImages']}');
|
||||
print('- Voyages sans image: ${newStats['tripsWithoutImages']}');
|
||||
} else {
|
||||
print('✅ Aucune image à nettoyer');
|
||||
}
|
||||
|
||||
print('\n✅ Script terminé avec succès');
|
||||
|
||||
} catch (e) {
|
||||
print('❌ Erreur lors du nettoyage: $e');
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Instructions d'utilisation:
|
||||
|
||||
1. Ouvrez votre application Flutter
|
||||
2. Connectez-vous à votre compte
|
||||
3. Dans le code de votre app, ajoutez temporairement:
|
||||
print('User ID: ${FirebaseAuth.instance.currentUser?.uid}');
|
||||
4. Récupérez votre User ID affiché dans la console
|
||||
5. Remplacez 'YOUR_USER_ID_HERE' par votre ID dans ce script
|
||||
6. Exécutez: dart run scripts/cleanup_images.dart
|
||||
*/
|
||||
Reference in New Issue
Block a user