# /opt/docker/dev/service_finder/backend/app/workers/vehicle/mapping_rules.py

SOURCE_MAPPINGS = {
    "os-vehicle-db": {
        "make": "brand",
        "model": "model_name",
        "year": "release_year",
        "power": "specs.engine.hp"
    },
    "car-query": {
        "make": "model_make_id",
        "model": "model_name",
        "year": "model_year",
        "power": "model_engine_power_ps"
    }
}

def unify_data(raw_data, source_name):
    mapping = SOURCE_MAPPINGS.get(source_name, {})
    unified = {
        "normalized_make": raw_data.get(mapping.get("make"), "").upper(),
        "normalized_model": raw_data.get(mapping.get("model"), "").upper(),
        "normalized_year": raw_data.get(mapping.get("year")),
        "raw_specs": raw_data # Megtartjuk az eredetit is
    }
    return unified