Some checks failed
CI / Lint (pull_request) Has been cancelled
CI / Schema map up to date (pull_request) Has been cancelled
CI / Forbidden patterns (9 checks) (pull_request) Has been cancelled
CI / Migrations apply (node-pg-migrate) (pull_request) Has been cancelled
Visual diff / Should run? (pull_request) Has been cancelled
CI / Unit tests (vitest) (pull_request) Has been cancelled
Convoy metrics gate / Require role-event telemetry on convoy PRs (pull_request) Has been cancelled
PR Health rollup / Aggregate gate status (pull_request) Has been cancelled
Preview smoke / Should run? (pull_request) Has been cancelled
Preview smoke / Playwright smoke (pull_request) Has been cancelled
Visual diff / Screenshot diff (pull_request) Has been cancelled
Add pricing schema, free API integrations (MTG bulk, TCGdex, Foolio), valuation and sort-by-price, card detail pricing UI, and nearby store discovery via home zip and OSM geo clients. Co-authored-by: Cursor <cursoragent@cursor.com>
19 lines
715 B
JavaScript
19 lines
715 B
JavaScript
/**
|
|
* SQL expression for foil-aware unit price on user-owned rows.
|
|
*
|
|
* @param {{ cardAlias?: string, userCardAlias?: string }} [options]
|
|
* @returns {string}
|
|
*/
|
|
export function effectiveUnitPriceExpr({ cardAlias = 'c', userCardAlias = 'uc' } = {}) {
|
|
return `CASE WHEN ${userCardAlias}.is_foil THEN ${cardAlias}.market_price ELSE COALESCE(${cardAlias}.current_price, ${cardAlias}.market_price) END`;
|
|
}
|
|
|
|
/**
|
|
* SQL expression for list/catalog unit price (no per-row foil flag on collection_cards).
|
|
*
|
|
* @param {{ cardAlias?: string }} [options]
|
|
* @returns {string}
|
|
*/
|
|
export function listUnitPriceExpr({ cardAlias = 'c' } = {}) {
|
|
return `COALESCE(${cardAlias}.current_price, ${cardAlias}.market_price)`;
|
|
}
|