BuyingAgent/backend/scripts/seed_notebook_pilot.py
Lars b276758ee1
All checks were successful
Deploy Development / deploy (push) Successful in 1m19s
Test Suite / pytest-backend (push) Successful in 31s
Test Suite / smoke-dev (push) Successful in 0s
Test Suite / frontend-checks (push) Successful in 28s
Stelle den Frontend-MVP und die v0.3-API auf develop bereit, damit Dev API und PWA zusammen deployen.
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-10-04 13:04:59 +02:00

82 lines
2.7 KiB
Python

"""Notebook-pilot metadata only. Not part of the core schema or bootstrap."""
from __future__ import annotations
from sqlalchemy.orm import Session
from app.discovery.definitions import get_definition_by_key, upsert_definition
from app.persistence.models import AttributeDefinitionRecord
from app.services.catalog_service import ensure_product_category
NOTEBOOK_ATTRIBUTE_SEEDS = (
{"key": "ram_gb", "value_type": "number", "canonical_unit": "GB", "minimum": 0},
{"key": "storage_gb", "value_type": "number", "canonical_unit": "GB", "minimum": 0},
{"key": "weight_kg", "value_type": "number", "canonical_unit": "kg", "minimum": 0},
{"key": "battery_score", "value_type": "number", "minimum": 0, "maximum": 100},
{"key": "display_score", "value_type": "number", "minimum": 0, "maximum": 100},
{"key": "cpu_score", "value_type": "number", "minimum": 0, "maximum": 100},
)
NOTEBOOK_CRITERION_SEEDS = (
{
"key": "ram_gb",
"origin": "SOURCE",
"source": "geizhals",
"product_category_id": "notebook",
"label": "Arbeitsspeicher",
"value_type": "number",
"unit": "GB",
"semantic": "working_memory",
"category": "notebook",
"scoring_attribute_key": "ram_gb",
},
{
"key": "storage_gb",
"origin": "SOURCE",
"source": "geizhals",
"product_category_id": "notebook",
"label": "SSD",
"value_type": "number",
"unit": "GB",
"semantic": "storage",
"category": "notebook",
"scoring_attribute_key": "storage_gb",
},
{
"key": "weight_kg",
"origin": "SOURCE",
"source": "geizhals",
"product_category_id": "notebook",
"label": "Gewicht",
"value_type": "number",
"unit": "kg",
"semantic": "weight",
"category": "notebook",
"scoring_attribute_key": "weight_kg",
},
{
"key": "price_eur",
"origin": "SOURCE",
"source": "geizhals",
"product_category_id": "notebook",
"label": "Preis",
"value_type": "number",
"unit": "EUR",
"semantic": "price",
"category": "notebook",
"scoring_attribute_key": "price_eur",
},
)
def seed_notebook_pilot(session: Session) -> None:
ensure_product_category(session, "notebook", "Notebooks")
for item in NOTEBOOK_ATTRIBUTE_SEEDS:
if session.get(AttributeDefinitionRecord, item["key"]) is None:
session.add(AttributeDefinitionRecord(**item, description=None))
for item in NOTEBOOK_CRITERION_SEEDS:
if get_definition_by_key(session, item["key"]) is None:
upsert_definition(session, item)
session.flush()