Files
fn_registry/python/functions/metabase/metabase_dashboard_next_row.md
egutierrez 20f72edb5a feat(metabase): auto-commit con 17 cambios
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-13 18:40:22 +02:00

2.2 KiB

name, kind, lang, domain, version, purity, signature, description, tags, uses_functions, uses_types, returns, returns_optional, error_type, imports, params, output, tested, tests, test_file_path, file_path
name kind lang domain version purity signature description tags uses_functions uses_types returns returns_optional error_type imports params output tested tests test_file_path file_path
metabase_dashboard_next_row function py infra 1.0.0 impure def metabase_dashboard_next_row(client: MetabaseClient, *, dashboard_id: int, tab_id: int = 0) -> int Calcula la primera fila libre al final de una tab de dashboard: max(dc.row + dc.size_y) entre las dashcards de esa tab. Retorna 0 si la tab esta vacia. Evita el boilerplate manual de max() al colocar nuevas cards al final del dashboard.
metabase
dashboard
layout
dashcard
row
tab
api
python
metabase_get_dashboard_py_infra
false error_go_core
name desc
client MetabaseClient autenticado con sesion activa
name desc
dashboard_id ID del dashboard cuyas filas se calculan
name desc
tab_id ID de la tab cuya fila final se calcula. 0 (default) = dashcards sin dashboard_tab_id (dashboard sin pestanas o tab raiz)
int: indice de fila (0-indexed) donde colocar la siguiente card. 0 si la tab no tiene dashcards. false
python/functions/metabase/metabase_dashboard_next_row.py

Ejemplo

from metabase import MetabaseClient, metabase_dashboard_next_row

client = MetabaseClient("https://metabase.example.com", "token...")

# Dashboard sin tabs: siguiente fila libre en la raiz
next_row = metabase_dashboard_next_row(client, dashboard_id=10)

new_dashcard = {
    "id": -1,
    "card_id": 99,
    "col": 0, "row": next_row, "size_x": 6, "size_y": 4,
    "parameter_mappings": [],
    "visualization_settings": {},
}

# Dashboard con tabs: siguiente fila libre en tab 3
next_row = metabase_dashboard_next_row(client, dashboard_id=10, tab_id=3)

Notas

  • Cuando tab_id == 0 se filtran dashcards donde dashboard_tab_id es falsy (None, 0 o ausente). Esto cubre dashboards sin tabs y la "tab raiz".
  • Requiere 1 request HTTP (GET dashboard). Si ya tienes el objeto dashboard en memoria, es mas eficiente calcular directamente: max((dc["row"] + dc["size_y"] for dc in dashcards), default=0).
  • La fila retornada es la inmediatamente disponible — no reserva espacio ni verifica solapamiento de columnas.