chore: auto-commit (10 archivos)
- scratchpad/ap.parquet - scratchpad/bq.py - scratchpad/cards.json - scratchpad/citas_recon.csv - scratchpad/dash.txt - scratchpad/diego.parquet - scratchpad/diego_literals.sql - scratchpad/exf/ - scratchpad/va.parquet - scratchpad/vm.parquet Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
import json, sys
|
||||
sys.path.insert(0, "scratchpad/exf")
|
||||
from build import api
|
||||
|
||||
C = json.load(open("scratchpad/exf/cards.json"))
|
||||
COLLECTION = 583
|
||||
|
||||
# 1) crear dashboard vacio
|
||||
dash = api("POST", "/api/dashboard", {
|
||||
"name": "Venta Web por Canal y Forma de Pago (facturacion NAV / modelo 4494)",
|
||||
"collection_id": COLLECTION,
|
||||
"description": "Solo venta web (origen precaweb) tomada del modelo 4494 (SUM Base_imponible_linea, facturacion NAV neta), desglosada por canal (channel_id) y forma de pago (pago web vs pago tienda), segun las convenciones del dashboard 1094. Glass excluido. Default: YTD 2026.",
|
||||
})
|
||||
DID = dash["id"]
|
||||
print("dashboard id:", DID)
|
||||
|
||||
# 2) parametros del dashboard
|
||||
PARAMS = [
|
||||
{"id":"p_desde","name":"Fecha desde","slug":"fecha_desde","type":"date/single","default":"2026-01-01"},
|
||||
{"id":"p_hasta","name":"Fecha hasta","slug":"fecha_hasta","type":"date/single"},
|
||||
{"id":"p_centro","name":"Centro","slug":"centro","type":"string/=","sectionId":"string"},
|
||||
{"id":"p_ensena","name":"Ensena","slug":"ensena","type":"string/=","sectionId":"string"},
|
||||
]
|
||||
|
||||
def mappings(cid):
|
||||
return [
|
||||
{"parameter_id":"p_desde","card_id":cid,"target":["variable",["template-tag","fecha_desde"]]},
|
||||
{"parameter_id":"p_hasta","card_id":cid,"target":["variable",["template-tag","fecha_hasta"]]},
|
||||
{"parameter_id":"p_centro","card_id":cid,"target":["variable",["template-tag","centro"]]},
|
||||
{"parameter_id":"p_ensena","card_id":cid,"target":["variable",["template-tag","ensena"]]},
|
||||
]
|
||||
|
||||
# 3) layout (grid 24 col)
|
||||
LAYOUT = {
|
||||
"total": (0, 0, 6, 4),
|
||||
"pago": (0, 6, 18, 4),
|
||||
"canal": (4, 0, 12, 7),
|
||||
"matriz": (4, 12, 12, 7),
|
||||
"evolutivo": (11, 0, 24, 7),
|
||||
}
|
||||
dashcards = []
|
||||
neg = -1
|
||||
for k,(row,col,sx,sy) in LAYOUT.items():
|
||||
cid = C[k]
|
||||
dashcards.append({
|
||||
"id": neg, "card_id": cid, "row": row, "col": col, "size_x": sx, "size_y": sy,
|
||||
"series": [], "parameter_mappings": mappings(cid), "visualization_settings": {}
|
||||
})
|
||||
neg -= 1
|
||||
|
||||
r = api("PUT", f"/api/dashboard/{DID}", {"dashcards": dashcards, "parameters": PARAMS})
|
||||
print("dashcards saved:", len(r.get("dashcards",[])))
|
||||
print("URL: https://reports.autingo.es/dashboard/%d" % DID)
|
||||
json.dump({"dashboard_id":DID}, open("scratchpad/exf/dash.json","w"))
|
||||
Reference in New Issue
Block a user