Add library_stats aggregate query for the sidebar summary
New LibraryStats (unique cards owned, total copies, deck count, and per-color copy counts including colorless) via Catalog::library_stats, tested against the fixture catalog. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -139,6 +139,22 @@ pub struct Deck {
|
||||
pub notes: String,
|
||||
}
|
||||
|
||||
/// Aggregate stats about the owned library, for a dashboard-style summary.
|
||||
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
|
||||
pub struct LibraryStats {
|
||||
/// Distinct oracle cards owned (quantity_owned > 0).
|
||||
pub unique_cards: i64,
|
||||
/// Total physical copies owned, summed across all cards.
|
||||
pub total_copies: i64,
|
||||
pub deck_count: i64,
|
||||
/// Copies owned in each color, WUBRG order. A multicolor card's copies
|
||||
/// count toward every color it contains, so these can sum to more than
|
||||
/// `total_copies`.
|
||||
pub color_counts: [i64; 5],
|
||||
/// Copies owned with no color (colors == 0).
|
||||
pub colorless_count: i64,
|
||||
}
|
||||
|
||||
/// Criteria for searching the owned library. All fields are optional; an empty
|
||||
/// filter matches every owned card.
|
||||
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
|
||||
|
||||
Reference in New Issue
Block a user