Add collector fields, including market value
Rating, notes, condition, region, purchase price and date, plus a market
value carrying the timestamp and source that make it interpretable.
Condition is load-bearing rather than cosmetic: price feeds quote per
condition, so it selects which quoted price applies to a copy. Market value
records when it was captured and where it came from — a collection total is
only as good as its staleness — and an edit to an unrelated field leaves
that timestamp alone, so a stale price cannot start looking freshly checked.
Two storage decisions worth naming:
* Money is stored as integer minor units. SQLite has no decimal type and
EF Core maps decimal to TEXT, which compares lexically: "9.00" sorts
above "10.00" and SUM is unavailable. A value converter keeps decimals
in C# while ordering and totalling work. A test pins the ordering.
* Enums serialise as names. The default is ordinals, which meant the API
rejected the browser's {"condition":"Cib"} with a 400 while the C# tests
passed, because they round-tripped ints and never spoke the client's
dialect. The tests now share the API's serializer options.
Also fixes a data-loss bug in the Python tools. Both built their PUT body
from a hardcoded list of field names, so any column added to the model was
omitted and therefore nulled. Adding collector fields meant the next art or
enrichment run would have erased every rating, note, condition, price and
valuation in the library. Payloads are now built by excluding the handful of
server-owned fields, so new columns carry through by default.
The migration was rehearsed against a copy of the live database before being
applied: 105 rows, descriptions and developers intact.
67 backend tests, 8 frontend.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -1,5 +1,26 @@
|
||||
/** Mirrors the API contracts in backend/src/LudosData.Api/Contracts. */
|
||||
|
||||
/** Mirrors LudosData.Api.Domain.GameCondition. */
|
||||
export type GameCondition = 'Unspecified' | 'Loose' | 'Cib' | 'Sealed' | 'Digital';
|
||||
|
||||
/** Mirrors LudosData.Api.Domain.GameRegion. */
|
||||
export type GameRegion = 'Unspecified' | 'Ntsc' | 'Pal' | 'NtscJ';
|
||||
|
||||
export const CONDITIONS: { value: GameCondition; label: string }[] = [
|
||||
{ value: 'Unspecified', label: '—' },
|
||||
{ value: 'Loose', label: 'Loose (cart/disc only)' },
|
||||
{ value: 'Cib', label: 'Complete in box' },
|
||||
{ value: 'Sealed', label: 'Sealed' },
|
||||
{ value: 'Digital', label: 'Digital' },
|
||||
];
|
||||
|
||||
export const REGIONS: { value: GameRegion; label: string }[] = [
|
||||
{ value: 'Unspecified', label: '—' },
|
||||
{ value: 'Ntsc', label: 'NTSC (North America)' },
|
||||
{ value: 'Pal', label: 'PAL (Europe/Australia)' },
|
||||
{ value: 'NtscJ', label: 'NTSC-J (Japan)' },
|
||||
];
|
||||
|
||||
export interface Game {
|
||||
id: number;
|
||||
title: string;
|
||||
@@ -17,6 +38,22 @@ export interface Game {
|
||||
dumped: boolean;
|
||||
played: boolean;
|
||||
finished: boolean;
|
||||
|
||||
/** Personal score out of 10. Null means unrated, which is not zero. */
|
||||
rating: number | null;
|
||||
notes: string | null;
|
||||
condition: GameCondition;
|
||||
region: GameRegion;
|
||||
|
||||
/** What was paid. A fixed historical fact. */
|
||||
purchasePrice: number | null;
|
||||
purchaseDate: string | null;
|
||||
|
||||
/** Current estimated resale value, with when and where it came from. */
|
||||
marketValue: number | null;
|
||||
marketValueUpdatedAt: string | null;
|
||||
marketValueSource: string | null;
|
||||
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
}
|
||||
@@ -35,6 +72,14 @@ export interface GameRequest {
|
||||
dumped: boolean;
|
||||
played: boolean;
|
||||
finished: boolean;
|
||||
rating: number | null;
|
||||
notes: string | null;
|
||||
condition: GameCondition;
|
||||
region: GameRegion;
|
||||
purchasePrice: number | null;
|
||||
purchaseDate: string | null;
|
||||
marketValue: number | null;
|
||||
marketValueSource: string | null;
|
||||
}
|
||||
|
||||
export interface PagedResult<T> {
|
||||
@@ -105,4 +150,12 @@ export const EMPTY_GAME: GameRequest = {
|
||||
dumped: false,
|
||||
played: false,
|
||||
finished: false,
|
||||
rating: null,
|
||||
notes: null,
|
||||
condition: 'Unspecified',
|
||||
region: 'Unspecified',
|
||||
purchasePrice: null,
|
||||
purchaseDate: null,
|
||||
marketValue: null,
|
||||
marketValueSource: null,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user