Phase 6b/7b: per-child decoded periods, separate brief blocks, idempotent calendar (AUD-119)
- Parse each child's own "Today" day widget for the timetable (FR-16); drop the school-wide week calendar's lesson grid and clean the leaked routine rows. - Add the editable codes map (FR-17): subjects, rooms, teachers and period labels, seeded, an unknown code falls back to the raw code; `school codes` CLI. - Brief: Finn's block first, then Harry's, four sections always present (FR-9); periods decoded into plain English; the undated tail is one counted line (FR-18). - Calendar: write periods + work due + work overdue + major events, per child, on every pass. Identity is the stable per-item key, so a re-run never re-inserts (FR-8). morning-brief.sh now runs scan -> calendar push -> notify. - Day-widget labels are 12-hour: 1-6 read as PM, fixing afternoon periods. Proven live on .13: image 0.6.2-phase6b7b; both children's briefs decoded and separate; 35 events in calendar.school; runs 2 and 3 of the scan added nothing. Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
@@ -125,14 +125,11 @@ func calendarStatus(args []string) {
|
||||
os.Exit(1)
|
||||
}
|
||||
now := time.Now().In(cfg.Location)
|
||||
candidates, err := st.CalendarCandidates(ctx, nil, nil, calendar.StartOfDay(now), 0)
|
||||
pendingEvents, err := calendar.Pending(ctx, st, calendar.Options{Now: now})
|
||||
if err != nil {
|
||||
fmt.Fprintln(os.Stderr, "school calendar:", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
// Count events, not rows: a school-wide event is stored against each
|
||||
// child but written once.
|
||||
pendingEvents := len(calendar.GroupDuplicates(candidates))
|
||||
|
||||
if asJSON {
|
||||
out := struct {
|
||||
@@ -174,7 +171,7 @@ func calendarStatus(args []string) {
|
||||
} else {
|
||||
fmt.Printf("reachable yes\n")
|
||||
}
|
||||
fmt.Printf("pending events %d (important, not in the calendar yet)\n", pendingEvents)
|
||||
fmt.Printf("pending events %d (periods + due work + overdue + school events, not in the calendar yet)\n", pendingEvents)
|
||||
fmt.Printf("pushes %d (%d failed)\n", summary.Total, summary.Failed)
|
||||
if summary.Last != nil {
|
||||
state := "ok"
|
||||
@@ -272,7 +269,11 @@ func printCalendarResult(res calendar.Result, loc *time.Location) {
|
||||
if uid == "" {
|
||||
uid = "-"
|
||||
}
|
||||
fmt.Printf(" item %-5d %-6s %-10s %-45s uid=%s\n", ev.ItemID, ev.Child, start, truncate(ev.Title, 45), uid)
|
||||
kind := string(ev.Kind)
|
||||
if kind == "" {
|
||||
kind = "event"
|
||||
}
|
||||
fmt.Printf(" item %-5d %-8s %-6s %-10s %-45s uid=%s\n", ev.ItemID, kind, ev.Child, start, truncate(ev.Title, 45), uid)
|
||||
}
|
||||
for _, msg := range res.Errors {
|
||||
fmt.Fprintf(os.Stderr, "FAILED: %s\n", msg)
|
||||
@@ -285,9 +286,11 @@ func calendarEvents(args []string) {
|
||||
fs := flag.NewFlagSet("calendar events", flag.ContinueOnError)
|
||||
var (
|
||||
days int
|
||||
past int
|
||||
asJSON bool
|
||||
)
|
||||
fs.IntVar(&days, "days", 14, "how many days ahead to read")
|
||||
fs.IntVar(&past, "past", 1, "how many days back to read (overdue work sits in the past)")
|
||||
fs.BoolVar(&asJSON, "json", false, "print the events as JSON")
|
||||
_ = fs.Parse(args)
|
||||
|
||||
@@ -302,8 +305,9 @@ func calendarEvents(args []string) {
|
||||
defer st.Close()
|
||||
|
||||
now := time.Now().In(cfg.Location)
|
||||
start := now.AddDate(0, 0, -past)
|
||||
end := now.AddDate(0, 0, days)
|
||||
events, err := client.Events(ctx, now.Add(-24*time.Hour), end)
|
||||
events, err := client.Events(ctx, start, end)
|
||||
if err != nil {
|
||||
fmt.Fprintln(os.Stderr, "school calendar:", err)
|
||||
os.Exit(1)
|
||||
@@ -321,7 +325,7 @@ func calendarEvents(args []string) {
|
||||
if len(events) == 0 {
|
||||
fmt.Printf("no events on %s between %s and %s\n",
|
||||
cfg.Calendar.EntityID,
|
||||
now.Format("2006-01-02 15:04"),
|
||||
start.Format("2006-01-02 15:04"),
|
||||
end.Format("2006-01-02 15:04"))
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user