Add card USD pricing and a deck maybeboard
Prices come from Scryfall's prices.usd on printings, shown as a hover badge on card tiles. The price is picked independently of whichever printing supplies the display image (the cheapest known price across all printings), since the display printing is often a promo/variant with no listed price. The maybeboard lets a deck track cards under consideration without counting them in deck analysis stats or library assignment totals. Cards move between mainboard and maybeboard via a per-card toggle; maybeboarding the commander clears commander status. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -16,6 +16,7 @@ const LIBRARY_MIGRATIONS: &[&str] = &[
|
||||
include_str!("sql/library/0001_init.sql"),
|
||||
include_str!("sql/library/0002_location.sql"),
|
||||
include_str!("sql/library/0003_deck_format.sql"),
|
||||
include_str!("sql/library/0004_deck_maybeboard.sql"),
|
||||
];
|
||||
|
||||
/// The attached alias under which the reference db is available at runtime.
|
||||
@@ -34,6 +35,19 @@ pub fn image_subquery(column: &str) -> String {
|
||||
)
|
||||
}
|
||||
|
||||
/// Correlated subquery selecting the cheapest known USD price across *all*
|
||||
/// printings of the oracle card aliased `oc` — deliberately independent of
|
||||
/// [`image_subquery`]'s printing choice, since the printing that happens to
|
||||
/// supply the display image (first by rowid) is often a promo/variant with no
|
||||
/// listed price even when other printings of the same card do have one.
|
||||
/// Returns NULL (read as 0.0) when no printing has a known price.
|
||||
pub fn price_subquery() -> String {
|
||||
format!(
|
||||
"(SELECT MIN(p.price_usd) FROM {REF_DB}.printings p
|
||||
WHERE p.oracle_id = oc.oracle_id AND p.price_usd > 0)"
|
||||
)
|
||||
}
|
||||
|
||||
/// Create (if needed) and open a reference.db, applying the reference schema.
|
||||
/// Used by the ingester and by test fixtures.
|
||||
pub fn open_reference_for_build(path: &Path) -> Result<Connection> {
|
||||
|
||||
Reference in New Issue
Block a user