69 lines
2.5 KiB
Rust
69 lines
2.5 KiB
Rust
use diesel::prelude::*;
|
|
use diesel::sqlite::SqliteConnection;
|
|
use std::env;
|
|
|
|
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|
let database_url = env::var("DATABASE_URL").unwrap_or_else(|_| "../cursebreaker.db".to_string());
|
|
let mut conn = SqliteConnection::establish(&database_url)?;
|
|
|
|
// Check items with images
|
|
#[derive(Queryable)]
|
|
struct ItemImageInfo {
|
|
id: Option<i32>,
|
|
name: String,
|
|
icon_large: Option<Vec<u8>>,
|
|
icon_medium: Option<Vec<u8>>,
|
|
icon_small: Option<Vec<u8>>,
|
|
}
|
|
|
|
use cursebreaker_parser::schema::items::dsl::*;
|
|
|
|
// Count items with images
|
|
let all_items: Vec<ItemImageInfo> = items
|
|
.select((id, name, icon_large, icon_medium, icon_small))
|
|
.load(&mut conn)?;
|
|
|
|
let items_with_images = all_items.iter().filter(|item| item.icon_large.is_some()).count();
|
|
let items_without_images = all_items.len() - items_with_images;
|
|
|
|
println!("✅ Image Statistics:\n");
|
|
println!(" Total items: {}", all_items.len());
|
|
println!(" Items with icons: {}", items_with_images);
|
|
println!(" Items without icons: {}", items_without_images);
|
|
|
|
// Show sample images with sizes
|
|
println!("\n📸 Sample items with icons:\n");
|
|
|
|
for (i, item) in all_items.iter().filter(|item| item.icon_large.is_some()).take(5).enumerate() {
|
|
let large_size = item.icon_large.as_ref().map(|v| v.len()).unwrap_or(0);
|
|
let medium_size = item.icon_medium.as_ref().map(|v| v.len()).unwrap_or(0);
|
|
let small_size = item.icon_small.as_ref().map(|v| v.len()).unwrap_or(0);
|
|
let total_size = large_size + medium_size + small_size;
|
|
|
|
println!(
|
|
" {}. {} (ID: {})",
|
|
i + 1,
|
|
item.name,
|
|
item.id.unwrap_or(0)
|
|
);
|
|
println!(
|
|
" Large (256px): {:.1} KB | Medium (64px): {:.1} KB | Small (16px): {:.1} KB | Total: {:.1} KB",
|
|
large_size as f64 / 1024.0,
|
|
medium_size as f64 / 1024.0,
|
|
small_size as f64 / 1024.0,
|
|
total_size as f64 / 1024.0
|
|
);
|
|
}
|
|
|
|
// Calculate total storage used by images
|
|
let total_storage: usize = all_items.iter().map(|item| {
|
|
item.icon_large.as_ref().map(|v| v.len()).unwrap_or(0) +
|
|
item.icon_medium.as_ref().map(|v| v.len()).unwrap_or(0) +
|
|
item.icon_small.as_ref().map(|v| v.len()).unwrap_or(0)
|
|
}).sum();
|
|
|
|
println!("\n💾 Total image storage: {:.2} MB", total_storage as f64 / 1024.0 / 1024.0);
|
|
|
|
Ok(())
|
|
}
|