Game sync and live services for independent game developers (targeting itch.io)
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

at main 63 lines 2.0 kB view raw
1use anyhow::{Context, Result}; 2use rusqlite::Connection; 3 4const COST_PER_GB: f64 = 0.005; 5 6pub async fn show(database: &std::path::Path) -> Result<()> { 7 let conn = Connection::open(database).context("Failed to open database")?; 8 9 let developer_count: i64 = conn 10 .query_row("SELECT COUNT(*) FROM developers", [], |row| row.get(0)) 11 .unwrap_or(0); 12 13 let game_count: i64 = conn 14 .query_row("SELECT COUNT(*) FROM games", [], |row| row.get(0)) 15 .unwrap_or(0); 16 17 let gamer_count: i64 = conn 18 .query_row("SELECT COUNT(*) FROM gamers", [], |row| row.get(0)) 19 .unwrap_or(0); 20 21 let save_count: i64 = conn 22 .query_row("SELECT COUNT(*) FROM saves", [], |row| row.get(0)) 23 .unwrap_or(0); 24 25 let version_count: i64 = conn 26 .query_row("SELECT COUNT(*) FROM save_versions", [], |row| row.get(0)) 27 .unwrap_or(0); 28 29 let unused_invites: i64 = conn 30 .query_row( 31 "SELECT COUNT(*) FROM invites WHERE used_by IS NULL", 32 [], 33 |row| row.get(0), 34 ) 35 .unwrap_or(0); 36 37 let total_bytes: i64 = conn 38 .query_row( 39 "SELECT COALESCE(SUM(used_bytes), 0) FROM gamer_quotas", 40 [], 41 |row| row.get(0), 42 ) 43 .unwrap_or(0); 44 45 let total_gb = total_bytes as f64 / (1024.0 * 1024.0 * 1024.0); 46 let total_cost = total_gb * COST_PER_GB; 47 48 println!("Scratchback Statistics"); 49 println!("======================"); 50 println!("Developers: {}", developer_count); 51 println!("Games: {}", game_count); 52 println!("Gamers: {}", gamer_count); 53 println!("Saves: {}", save_count); 54 println!("Save versions: {}", version_count); 55 println!("Unused invites: {}", unused_invites); 56 println!(); 57 println!("Storage Cost (DO Spaces @ $0.005/GB)"); 58 println!("-------------------------------------"); 59 println!("Total storage: {:.6} GB", total_gb); 60 println!("Monthly cost: ${:.6}", total_cost); 61 62 Ok(()) 63}