Files
HiveGrid-Wireframes/03 Quellen und Referenzen/hivegrid-cloud/.planning/plane-sync/gen_dayplan.py
T

151 lines
8.9 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/usr/bin/env python3
"""
Generiert .planning/SPRINT-DAYPLAN.md DATENGETRIEBEN aus Plane (Single Source).
Jedes Ticket erscheint an seinem Start-Tag mit ID · Owner · Fenster (start→Ziel) · Aufgabe.
Counts pro Tag/Woche + vollständige Ticket-Index-Tabelle am Ende → garantiert nichts ausgelassen.
Neu rendern danach: npx md-to-pdf .planning/SPRINT-DAYPLAN.md
"""
import os, json, datetime, urllib.request
TOK={}
for ln in open(os.path.expanduser("~/.cli-tokens/plane")):
ln=ln.strip()
if "=" in ln and not ln.startswith("#"): k,v=ln.split("=",1); TOK[k.strip()]=v.strip()
B=TOK["PLANE_BASE_URL"].rstrip("/"); WS=TOK["PLANE_WORKSPACE"]; KEY=TOK["PLANE_API_KEY"]
PID="35d0d968-8ab3-40cc-97b8-b81d917dc5df"
API=f"{B}/api/v1/workspaces/{WS}/projects/{PID}"
NAME={"8e34a88c-19c9-4565-b4f5-50415d623ce8":"Raffael","8bf43e86-dc8a-4963-b57a-aeb5f2cc450a":"Akeshan",
"6c1fc63f-133d-4f40-86e4-7f658a6edcc7":"David","a5883f5e-3038-453c-9401-39ab1f40be9e":"Dejan",
"48367c1f-20d2-44f1-8ae2-faf35aa2052a":"Haris"}
def call(path):
r=urllib.request.Request(API+path); r.add_header("X-API-Key",KEY)
return json.loads(urllib.request.urlopen(r,timeout=30).read())
labs={l["id"]:l["name"] for l in call("/labels/").get("results",[])}
states={s["id"]:s["name"] for s in call("/states/").get("results",[])}
issues=[]; cur=None
while True:
d=call("/issues/"+("?cursor="+cur if cur else ""))
issues+=d.get("results",[])
if d.get("next_page_results") and d.get("next_cursor"): cur=d["next_cursor"]
else: break
T=[]; V3=[]
for i in issues:
nm=i["name"]
if " · " not in nm: continue
if states.get(i.get("state"))=="Cancelled": continue # aufgelöste/abgesagte Tickets nicht im Sprint-Plan
wid,title=nm.split(" · ",1)
lset={labs.get(x,"") for x in i.get("labels",[])}
asg=[NAME.get(a,"?") for a in i.get("assignees",[])] or ["—"]
# Noah-Tickets sind Haris+Dejan -> als Träger; Owner-Anzeige
who="/".join(asg)
rec={"wid":wid,"title":title.strip(),"who":who,
"start":(i.get("start_date") or "")[:10],"target":(i.get("target_date") or "")[:10],
"v":"v2" if "v2" in lset else "v1","b2":"block-2" in lset}
if "v3" in lset: V3.append(rec); continue # v3-Backlog: nicht im Sprint (PWA-only, AD-17)
T.append(rec)
T.sort(key=lambda x:(x["start"],x["wid"]))
V3.sort(key=lambda x:x["wid"])
WD={0:"Mo",1:"Di",2:"Mi",3:"Do",4:"Fr",5:"Sa",6:"So"}
def de(d): # 2026-06-16 -> "16.06."
return f"{d[8:10]}.{d[5:7]}." if d else "offen"
def wday(d):
y,m,dd=map(int,d.split("-")); return WD[datetime.date(y,m,dd).weekday()]
WEEKS=[
("Woche 1 · Di 16.–Fr 19.06. — Fundament & Identität","2026-06-16","2026-06-19","→ Gate W1 (Fr 19.06.)"),
("Woche 2 · Sa 20.–Fr 26.06. — Plattform + CRM","2026-06-20","2026-06-26","→ Gate W2 + Noah-Demo 1 (Fr 26.06.)"),
("Woche 3 · Sa 27.06.–Fr 03.07. — Kern-Kette + Kommunikation","2026-06-27","2026-07-03","→ Gate W3 + Noah-Demo 2 (Fr 03.07.)"),
("Woche 4 · Sa 04.–Fr 10.07. — USP, Härtung, Launch","2026-07-04","2026-07-10","→ Freeze (Do 09.) · LAUNCH (Fr 10.07.)"),
("v2-Woche 1 · Mo 13.–So 19.07. — Public-API / Postfach / Abo / MCP","2026-07-13","2026-07-19","→ Webinar Nr. 1 (Di/Mi 14./15.07.)"),
("v2-Woche 2 · Mo 20.–So 26.07. — KWP / Portal / Mobile","2026-07-20","2026-07-26","→ KWP-Sync-E2E mit Geerkens (Fr 24.07.)"),
("v2-Woche 3 · Mo 27.–Fr 31.07. — Admin / Help / Dashboard","2026-07-27","2026-07-31","→ ursprüngliches Wochengate; Customer-Portal folgt nach VA-P26b/VA-P26c"),
]
GATE_DAY={"2026-06-19","2026-06-26","2026-07-03","2026-07-09","2026-07-10","2026-07-24","2026-07-31"}
CSS = """ body { font-family: -apple-system, "Segoe UI", Helvetica, Arial, sans-serif; font-size: 9px; color: #1f2937; line-height: 1.4; }
h1 { font-size: 21px; margin: 0 0 2px; color: #0f172a; }
p.lead { color: #475569; font-size: 10.5px; margin: 0 0 4px; }
p.meta { color: #64748b; font-size: 8.5px; margin: 0 0 10px; }
h2 { font-size: 14px; color: #b45309; border-bottom: 2.5px solid #f5a623; padding-bottom: 4px; margin: 0 0 8px; page-break-before: always; break-before: page; break-after: avoid; page-break-after: avoid; }
h2.idx { page-break-before: always; }
h3 { font-size: 10.5px; margin: 12px 0 3px; color: #0f766e; break-after: avoid; page-break-after: avoid; }
h3.gate { color: #b91c1c; }
table { font-size: 8.5px; border-collapse: collapse; width: 100%; margin: 0 0 5px; break-inside: avoid; page-break-inside: avoid; }
thead { display: table-header-group; }
tr { break-inside: avoid; page-break-inside: avoid; }
td, th { border: 1px solid #e2e8f0; padding: 3px 6px; text-align: left; vertical-align: top; break-inside: avoid; page-break-inside: avoid; }
th { background: #fff7e8; color: #92400e; font-size: 8px; text-transform: uppercase; letter-spacing: 0.3px; }
td:nth-child(1) { font-family: "SF Mono", Menlo, monospace; font-weight: 600; color: #0f172a; white-space: nowrap; width: 70px; }
td:nth-child(2) { white-space: nowrap; width: 62px; color: #334155; }
td:nth-child(3) { white-space: nowrap; width: 42px; color: #64748b; }
tr.b2 td:nth-child(1) { color: #b91c1c; }
strong { color: #b45309; }"""
out=[]
out.append("---\npdf_options:\n format: A4\n margin: 13mm\n printBackground: true\ncss: |-\n"+CSS+"\n---\n")
out.append("# HiveGrid 2.0 — Sprint-Tagesplan (ticket-genau)\n")
out.append('<p class="lead">Jedes Ticket an seinem Start-Tag · ID · Wer · Fenster (Start→Ziel) · Aufgabe · '+f'{len(T)} Sprint-Tickets (v1: {sum(1 for t in T if t["v"]=="v1")} · v2: {sum(1 for t in T if t["v"]=="v2")})'+(f' + {len(V3)} v3-Backlog' if V3 else '')+'</p>')
out.append('<p class="meta">Generiert aus Plane (Single Source) · Arbeitsrhythmus Mo–So ≥8 h · „bis" = Ziel-/Fertig-Datum (Mehrtages-Tickets laufen bis dahin) · rot = Meilenstein/Gate-Tag · <span style="color:#b91c1c">rote Ticket-ID</span> = Block 2 (Partner-API offen, agil). Neu erzeugen: <code>python3 .planning/plane-sync/gen_dayplan.py</code></p>')
def table(items):
r=['| Ticket | Wer | bis | Aufgabe |','|---|---|---|---|']
for t in items:
r.append(f'| {t["wid"]}{(" •B2" if t["b2"] else "")} | {t["who"]} | {de(t["target"])} | {t["title"]} |')
return "\n"+"\n".join(r) # führende Leerzeile: trennt Tabelle sauber vom Vor-Block
assigned=set()
for wtitle,ws,we,gate in WEEKS:
wk=[t for t in T if ws<=t["start"]<=we]
assigned.update(id(t) for t in wk)
out.append(f"\n## {wtitle} · {len(wk)} Tickets")
out.append(f"*{gate}*")
# nach Tag gruppieren
days=sorted({t["start"] for t in wk})
for d in days:
dt=[t for t in wk if t["start"]==d]
cls="gate" if d in GATE_DAY else ""
head=f'{wday(d)} {de(d)} · {len(dt)} Ticket(s)'
if cls: out.append(f'<h3 class="gate">{head}</h3>\n')
else: out.append(f"### {head}")
out.append(table(dt))
# Retimierte Tickets nach dem ursprünglichen Drei-Wochen-Plan und bewusst undatierter Backlog.
carry=[t for t in T if id(t) not in assigned and t["start"]]
undated=[t for t in T if id(t) not in assigned and not t["start"]]
if carry:
out.append(f"\n## v2-Carry-over ab 01.08. · {len(carry)}")
out.append("*Retimierte Arbeit außerhalb des ursprünglichen Drei-Wochen-Fensters.*")
out.append(table(carry))
if undated:
out.append(f"\n## Termin offen / Backlog · {len(undated)}")
out.append("*Bewusst nicht auf ein Datum gelegt; Abhängigkeiten zuerst erfüllen.*")
out.append(table(undated))
# v3-Backlog (zurückgestellt, nicht im Sprint — PWA-only, AD-17)
if V3:
out.append(f"\n## v3-Backlog (zurückgestellt — NICHT im Sprint) · {len(V3)}")
out.append("*PWA-only (AD-17): native App + App-Store erst v3. Diese Tickets sind keinem Cycle zugeordnet.*")
out.append(table(V3))
# Vollständige Index-Tabelle, nach Track gruppiert (jede Tabelle eigener Header)
out.append('\n<h2 class="idx">Ticket-Index — alle '+str(len(T))+' Tickets (nach Track)</h2>')
out.append("*Zum Nachschlagen, je Track nach Start sortiert. •B2 = Block 2 (Partner-API offen, agil).*")
def idx_table(items):
r=['','| Ticket | Start | bis | v | Aufgabe |','|---|---|---|---|---|']
for t in sorted(items,key=lambda x:x["start"]):
r.append(f'| {t["wid"]}{(" •B2" if t["b2"] else "")} | {de(t["start"])} | {de(t["target"])} | {t["v"]} | {t["title"]} |')
return "\n".join(r)
ORDER=["Raffael","Akeshan","David","Dejan","Haris"]
groups=sorted({t["who"] for t in T}, key=lambda w:(ORDER.index(w) if w in ORDER else len(ORDER), w))
for who in groups:
grp=[t for t in T if t["who"]==who]
label=who+(" (Noah-Zulieferungen)" if "/" in who else "")
out.append(f'\n### {label} · {len(grp)} Tickets')
out.append(idx_table(grp))
open(".planning/SPRINT-DAYPLAN.md","w",encoding="utf-8").write("\n".join(out)+"\n")
print(f"Geschrieben: {len(T)} Tickets, {len(WEEKS)} Wochen, Carry-over: {len(carry)}, Termin offen: {len(undated)}")
for wtitle,ws,we,_ in WEEKS:
print(f" {wtitle.split(' — ')[0]:42} {sum(1 for t in T if ws<=t['start']<=we)} Tickets")