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:
@@ -45,13 +45,16 @@ type Item struct {
|
||||
|
||||
// Page is one stored raw page: its slug, the URL it was fetched from, and the
|
||||
// bytes. HTML pages carry HTML; the JSON service page carries JSON and the
|
||||
// child's Compass userId (from the fetcher's meta file).
|
||||
// child's Compass userId (from the fetcher's meta file). FetchedAt is when the
|
||||
// fetcher stored the page, so a "Today" widget can be dated correctly even when
|
||||
// an old run is re-parsed.
|
||||
type Page struct {
|
||||
Slug string
|
||||
URL string
|
||||
HTML []byte
|
||||
JSON []byte
|
||||
UserID string
|
||||
Slug string
|
||||
URL string
|
||||
HTML []byte
|
||||
JSON []byte
|
||||
UserID string
|
||||
FetchedAt time.Time
|
||||
}
|
||||
|
||||
// Parse turns the stored pages for one child into structured items. It fails,
|
||||
@@ -96,30 +99,39 @@ func Parse(child string, pages []Page, loc *time.Location) ([]Item, error) {
|
||||
items = append(items, got.items...)
|
||||
recognised++
|
||||
case PageLearningTasks:
|
||||
if hasAuthoritativeTasks {
|
||||
recognised++
|
||||
continue
|
||||
if !hasAuthoritativeTasks {
|
||||
got, err := parseLearningTasks(child, p, loc)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
items = append(items, got...)
|
||||
}
|
||||
got, err := parseLearningTasks(child, p, loc)
|
||||
// The child's own day widget is the per-child timetable (FR-16).
|
||||
day, _, err := parseDayWidget(child, p, loc, p.FetchedAt)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
items = append(items, got...)
|
||||
items = append(items, day...)
|
||||
recognised++
|
||||
case PageChildProfile:
|
||||
// The React profile page has no server-rendered grid; when it does
|
||||
// carry the legacy grid, use it. The JSON list supersedes it.
|
||||
if hasAuthoritativeTasks {
|
||||
recognised++
|
||||
continue
|
||||
if !hasAuthoritativeTasks {
|
||||
got, found, err := extractLearningTasks(child, p, loc)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if found {
|
||||
items = append(items, got...)
|
||||
}
|
||||
}
|
||||
got, found, err := extractLearningTasks(child, p, loc)
|
||||
// The profile page carries the child's own "Today" widget: the
|
||||
// authoritative per-child periods (FR-16).
|
||||
day, _, err := parseDayWidget(child, p, loc, p.FetchedAt)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if found {
|
||||
items = append(items, got...)
|
||||
}
|
||||
items = append(items, day...)
|
||||
recognised++
|
||||
case PageHome:
|
||||
got, err := parseNews(child, p, loc)
|
||||
|
||||
Reference in New Issue
Block a user