d110aa40f9
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2.2 KiB
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. |
|
|
false | error_go_core |
|
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 == 0se filtran dashcards dondedashboard_tab_ides 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.