[ Case Study ]

Paperboy

A daily news digest and the monitor behind it. About two dozen publisher feeds are read every morning, and a source going quiet shows up as a row that changes, not a gap in the news.

  • React
  • TypeScript
  • Azure
  • Node.js

[ The Problem ]

A news feed is a list a publisher keeps of its latest stories. A digest built from feeds can lose a source without anything looking broken. The feed keeps answering normally while its stories stop changing, or the publisher starts refusing article requests, and the digest just gets a little shorter. Paperboy is a daily digest of about two dozen feeds with a monitor beside it, which shows which sources are failing, how, and for how long.

[ The Digest ]

Every morning, a run reads the feeds and builds that day's digest of full articles.

[ The Monitor ]

Each run also writes a report on every source. The monitor is built entirely from those reports, and gives each source one of seven states per run: Down, Blocked, Thin, Stale, Empty, Dry or OK.

Red and green are hard to tell apart with red-green color blindness, so no state depends on color alone. Each one has a name and a sentence saying what it means, and each problem state has its symbol in the grid. The interface is built on Loom, with amounts drawn in shades of one blue and Loom's status colors kept for problems.

[ Under the Hood ]

The code behind three of the rules above.

A source's state is worked out from one run's counts, checking the worst states first.

> src/monitor/health.ts
export function level(s: SourceReport): Level {
  if (s.feedStatus !== 200 || s.feedError) return 'down';
  if (s.itemsInFeed === 0) return 'empty';
  if (s.fetched > 0 && s.fetchErrors === s.fetched) return 'blocked';
  if (s.thin > s.articles) return 'thin';
  // A `seen` skip proves an item was inside the window; none, with `stale`
  // present, means nothing in the feed was fresh. Whether that is a dead
  // publisher or a quiet day is not knowable from one run.
  if (s.fetched === 0 && !s.skipped.seen && (s.skipped.stale ?? 0) > 0) return 'stale';
  if (s.fetched === 0) return 'dry';
  return 'ok';
}