feat(laptop): add laptop device category (engine)#39
Merged
Conversation
… validate) Introduces a new `laptop` device category end-to-end: - `app/models/laptop.py` — Laptop table; brand FK required, cpu/gpu FK optional (raw cpu_name/gpu_name always kept so a record is meaningful without a resolved component). Unscored. - `app/schemas/laptop.py` + serializer `laptop_read` — detail response embeds brand + optional cpu/gpu refs; no score field. - `app/routers/laptops.py` — list + detail with brand/cpu/gpu filters. - `app/main.py` — register the router. - `app/seed.py` — seed data/laptop/, resolve brand (required) + cpu/gpu (optional) FKs from slugs. - `app/dump.py` — add "laptops" to COLLECTIONS (not SCORED). - `app/validate.py` — LAPTOP_REQUIRED + ranges (ram 1-256, weight 300-6000, msrp 50-50000) + brand/cpu/gpu FK checks + variant path. - tests: laptop fixtures + integration tests (list, detail embeds, brand filter, 404, unscored). Paired with the TechAPI data PR that seeds data/laptop/ and mirrors the validate rule.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What & why
Adds a new
laptopdevice category to the engine, end-to-end, so TechAPI can carrydata/laptop/records that get validated, served and dumped like any other category. This is the engine half of the laptop rollout; the TechAPI data PR (seedingdata/laptop/+ mirroring the validate rule) is paired and merges after this.Design
cpu_name/gpu_nameare always stored andcpu_id/gpu_idare set only when the string resolves to an existing CPU/GPU — no FK bottleneck on import./scoreendpoint, not in the dumpSCOREDset. Scoring can be added later without schema churn.Changes
app/models/laptop.pyLaptoptableapp/models/__init__.pyapp/schemas/laptop.py+serializers.py+schemas/__init__.pyLaptopRead+laptop_read()app/routers/laptops.py+app/main.pyapp/seed.pydata/laptop/, resolve brand (req) + cpu/gpu (opt) FKsapp/dump.pylaptopsadded toCOLLECTIONS(notSCORED)app/validate.pyLAPTOP_REQUIRED+ ranges (ram 1–256, weight 300–6000, msrp 50–50000) + FK checks + variant pathtests/integration/{laptop_fixtures,test_laptops}.pyVerification
ruff check app tests✅ ·mypy app✅ (89 files)pytest tests/integration/test_laptops.py✅ (4 tests)/v1/laptopslist, detail (embeds brand + cpu/gpu refs, preserves rawcpu_name), brand filter, 404, andapp.dumpwritesv1/laptops/**+ manifest entry (noscoredkey). Existing endpoints unaffected;/v1/laptopspresent in OpenAPI.Tests use self-contained fixtures, so CI passes before any laptop data exists in TechAPI.