refactor: Clean up code by removing unnecessary whitespace and improving readability
This commit is contained in:
@@ -1,48 +1,47 @@
|
||||
import 'package:firebase_core/firebase_core.dart';
|
||||
import 'package:firebase_storage/firebase_storage.dart';
|
||||
import '../lib/firebase_options.dart';
|
||||
import 'package:travel_mate/firebase_options.dart';
|
||||
|
||||
/// Script de diagnostic pour analyser les images dans Firebase Storage
|
||||
void main() async {
|
||||
|
||||
try {
|
||||
// Initialiser Firebase
|
||||
await Firebase.initializeApp(
|
||||
options: DefaultFirebaseOptions.currentPlatform,
|
||||
);
|
||||
|
||||
|
||||
final storage = FirebaseStorage.instance;
|
||||
|
||||
|
||||
final listResult = await storage.ref('trip_images').listAll();
|
||||
|
||||
|
||||
if (listResult.items.isEmpty) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
final Map<String, List<Map<String, dynamic>>> locationGroups = {};
|
||||
|
||||
|
||||
for (int i = 0; i < listResult.items.length; i++) {
|
||||
final item = listResult.items[i];
|
||||
final fileName = item.name;
|
||||
|
||||
|
||||
|
||||
try {
|
||||
// Récupérer les métadonnées
|
||||
final metadata = await item.getMetadata();
|
||||
final customMeta = metadata.customMetadata ?? {};
|
||||
|
||||
|
||||
final location = customMeta['location'] ?? 'Inconnue';
|
||||
final normalizedLocation = customMeta['normalizedLocation'] ?? 'Non définie';
|
||||
final normalizedLocation =
|
||||
customMeta['normalizedLocation'] ?? 'Non définie';
|
||||
final source = customMeta['source'] ?? 'Inconnue';
|
||||
final uploadedAt = customMeta['uploadedAt'] ?? 'Inconnue';
|
||||
|
||||
|
||||
|
||||
// Récupérer l'URL de téléchargement
|
||||
final downloadUrl = await item.getDownloadURL();
|
||||
|
||||
|
||||
// Grouper par location normalisée
|
||||
final groupKey = normalizedLocation != 'Non définie' ? normalizedLocation : location.toLowerCase();
|
||||
final groupKey = normalizedLocation != 'Non définie'
|
||||
? normalizedLocation
|
||||
: location.toLowerCase();
|
||||
if (!locationGroups.containsKey(groupKey)) {
|
||||
locationGroups[groupKey] = [];
|
||||
}
|
||||
@@ -53,14 +52,12 @@ void main() async {
|
||||
'uploadedAt': uploadedAt,
|
||||
'downloadUrl': downloadUrl,
|
||||
});
|
||||
|
||||
} catch (e) {
|
||||
|
||||
// Essayer de deviner la location depuis le nom du fichier
|
||||
final parts = fileName.split('_');
|
||||
if (parts.length >= 2) {
|
||||
final guessedLocation = parts.take(parts.length - 1).join('_');
|
||||
|
||||
|
||||
if (!locationGroups.containsKey(guessedLocation)) {
|
||||
locationGroups[guessedLocation] = [];
|
||||
}
|
||||
@@ -73,30 +70,24 @@ void main() async {
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
// Analyser les doublons
|
||||
|
||||
|
||||
int totalDuplicates = 0;
|
||||
for (final entry in locationGroups.entries) {
|
||||
final location = entry.key;
|
||||
final images = entry.value;
|
||||
|
||||
|
||||
if (images.length > 1) {
|
||||
totalDuplicates += images.length - 1;
|
||||
|
||||
|
||||
for (int i = 0; i < images.length; i++) {
|
||||
final image = images[i];
|
||||
}
|
||||
} else {
|
||||
}
|
||||
} else {}
|
||||
}
|
||||
|
||||
|
||||
if (totalDuplicates > 0) {
|
||||
}
|
||||
|
||||
} catch (e) {
|
||||
}
|
||||
}
|
||||
|
||||
if (totalDuplicates > 0) {}
|
||||
} catch (e) {}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user