You're offline — showing cached data

Append latest B4i Fuel emails to SecondBrain note

b4i-fuel-history-update
2026-06-13 06:16:06 SAST
← Back to Tasks

B4i Fuel History — Weekly Auto-Update

Tuesday 15:00 SAST (13:00 UTC). Late buffer: Bernd typically sends Mon evening / Tue morning, so 15:00 catches stragglers.

What it does

  1. Reads ~/workspace/PKA/SecondBrain/wiki/concepts/Fuel-Prices-B4i.md — gets last_updated from frontmatter.
  2. Searches Outlook (m365 skill) for from:bernd@b4i.co.za subject:"B4i Fuel" since last_updated - 2 days (overlap window for late emails).
  3. For each new email (not already a ### YYYY-MM-DD section in the note):
  4. Reads body via graph_api.py read-message
  5. Strips HTML, takes only the TOP update (caps at first From: header in body)
  6. Formats as ### YYYY-MM-DD (Day) with yaml block (type/effective/trend) + bullet list of supplier/location moves
  7. Appends new sections in chronological order.
  8. Bumps last_updated: in frontmatter to today.
  9. Re-embeds the updated MD as base64 into the HTML report (~/workspace/reports/fuel-impact-2026-05-07.html — replaces the _MD_B64 constant).
  10. PKA auto-push commits changes.

Cadence

Telegram dest

elmar-pka topic — same as other FlySafair work.

Skip conditions

Cross-task notes

Failure modes

Manual trigger

python3 /home/lucienne/workspace/scheduler.py run b4i-fuel-history-update
Tue at 13:000 13 * * 2
Yes
shell
1800s
Yes
in 3d (2026-06-16 13:00)

Task Definition

tasks/b4i-fuel-history-update.md
shell
set
No
No
cd /home/lucienne/workspace/PKA && git pull --rebase --autostash --quiet 2>/dev/null || git rebase --abort 2>/dev/null; claude --settings ~/.claude/settings-worker.json --allowedTools Bash,Read,Edit,Glob,Grep -p "Two-part weekly fuel update.

PART 1 — B4i email history. Read ~/workspace/PKA/SecondBrain/wiki/concepts/Fuel-Prices-B4i.md. Get last_updated from frontmatter. Use python3 ~/.claude/skills/m365/scripts/graph_api.py search to find emails from bernd@b4i.co.za with subject 'B4i Fuel' since last_updated - 2 days. For each email NOT already represented (compare ### YYYY-MM-DD headings): read body, strip HTML, extract TOP update (cap at first ' From: ' header). Format as new '### YYYY-MM-DD (Day)' section using template at bottom. Append in chronological order. Bump last_updated.

PART 2 — Radixx surcharge files. Read ~/workspace/PKA/SecondBrain/wiki/concepts/Fuel-Surcharge-Radixx.md last_updated. Use Graph Search API via curl to query driveItems for 'Fuel levy' and 'April Fuel' since last_updated. For each new XLSX: download via Graph drive-item content endpoint to /tmp/fuel_levy/, parse with openpyxl (find 'Route Pair' header row, extract route + Final Surcharge Per Pax columns), append to ~/workspace/PKA/SecondBrain/wiki/concepts/fuel-surcharge-data/surcharge_history.{json,csv}. Update pivot table in the markdown note. Bump last_updated.

PART 3 — Refresh embedded base64 in ~/workspace/reports/fuel-impact-2026-05-07.html for the B4i note (replace _MD_B64= string with new base64 of Fuel-Prices-B4i.md). Update _SURCH_PIVOT JSON literal with new surcharge data.

Print summary: 'APPENDED N B4i emails, M surcharge weeks: ...' or 'NO NEW DATA'. PKA auto-push commits."
This task calls claude directly. If the scheduler profile is GLM, Kimi, or MiniMax, prefer ~/workspace/PKA/scripts/claude-provider-run.sh so backup providers run in API-key-only mode with explicit settings/MCP context.

Edit Schedule

Result:
1
Runs (7d)
1
Completed
0
Failed
0
Timeout
100%
Success (7d)
11.3m
Avg Duration
flysafair fuel b4i secondbrain

Run History (1)

StartedFinishedStatusDurationOutputLog
4d ago 4d ago completed 11.3m
Done. HTML is **gitignored** (`reports/**/*.html`) by design — on-disk refresh is the deliverable, no commit needed. PKA ...
View log

Comments (0)

No comments yet — add instructions for Luci
Help