"""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()