feat(watches): show the carrier's expected delivery date - #22
Merged
Conversation
Blue Dart and Delhivery both publish an expected delivery date, and the public tracking page has always shown it — but a watch never kept it, so the dashboard and the alert emails didn't. Persist it and surface it in both. - migration 0010 adds watches.estimated_delivery (TEXT, nullable). Stored as the carrier renders it rather than parsed into a date: each carrier formats it differently and it is only ever displayed verbatim, exactly as the track page already does. - the poller refreshes it on every *successful* poll, not only when a scan changes — carriers revise the date without adding an event, so tying it to status changes would leave a stale date on the dashboard for days. It is only written when the carrier actually returned one: a single flaky scrape can't wipe a date we already know (bluedart.ts is a scraper, so that matters). - the alert email gains an "Expected delivery" row in the shipment card, and a line in the plain-text part. It falls back to the stored value when the poll that triggered the alert didn't return one. - the dashboard shows it as a muted line under the status pill, mirroring the existing "auto-removes in N days" note, and hides it once a shipment is delivered or cancelled where an expected date is just noise. Deliberately not a new column: the table is already 7 wide in a 960px container and has a history of layout fixes. Shiprocket exposes no ETA, so those watches simply show nothing. Verified: email template rendered with / without / null ETA (row and text line present only when set, and html-escaped); dashboard rendered against local D1 with three seeded watches — active-with-ETA shows "expected 30 Aug 2026" after its status, active-without shows nothing, and the finished one is excluded. Migration applied to local and remote D1 ahead of this landing. tsc clean, poller bundles at 50.35 KiB, web build green. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Aswincloud-Bot
approved these changes
Aug 28, 2026
Aswincloud-Bot
left a comment
There was a problem hiding this comment.
Auto-approved: @Aswinmcw is a member of @Aswincloud/admins.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Blue Dart and Delhivery both publish an expected delivery date, and the public track page has always displayed it — but a watch never stored it, so the dashboard and the alert emails couldn't. This persists it and surfaces it in both places.
Changes
migrations/0010—watches.estimated_delivery(TEXT, nullable). Stored as the carrier renders it ("30 Aug 2026") rather than parsed into a date: each carrier formats it differently and it is only ever displayed verbatim, exactly assrc/app/track/.../page.tsxalready does.Poller — refreshes it on every successful poll, not only when a scan changes. Carriers revise the date without adding an event, so tying the write to status changes would leave a stale date sitting on the dashboard for days. It is written only when the carrier actually returned one, so a single flaky scrape can't wipe a date we already know —
bluedart.tsis an HTML scraper, so that failure mode is real.Alert email — an "Expected delivery" row in the shipment card, plus a line in the plain-text part. Falls back to the stored value when the poll that triggered the alert didn't return one.
Dashboard — a muted line under the status pill:
mirroring the existing "auto-removes in N days" note, and hidden once a shipment is delivered or cancelled, where an expected date is only noise. Deliberately not a new column — the table is already 7 wide inside a 960px container and this file has a history of layout fixes (
c52ce4a,9dd0d90).Shiprocket publishes no ETA, so those watches simply show nothing.
Verification
Email template, compiled and rendered directly:
Dashboard, rendered for real against local D1 with three seeded watches:
tsc --noEmitclean, poller bundles at 50.35 KiB,opennextjs-cloudflare buildgreen.Rollout
Migration 0010 is already applied to local and remote D1, ahead of this landing, so the column exists before any code reads or writes it. Adding it was additive and nullable; existing rows read
NULLand backfill on their next poll.Two halves land at different times, because the poller's production deploy is still disabled (its "Deploy default branch" trigger runs
wrangler versions uploadinstead ofwrangler deploy):NULLfor every existing watch until a poller carrying this change writes to itnpx wrangler deploy -c wrangler.poller.jsonc, or runnpm run deploy:polleronce