From O(n²) to O(n) — Optimizing a PostgreSQL Backfill Task
Fixing a backfill rake task that slowed to a crawl by replacing NULL-hunting with primary key range scans.
How Our Mail Piece Cost Calculation Actually Works
A deep dive into the 5-layer pipeline behind mail piece cost estimation — from product pricing tiers through weighted averages, caching, and admin UI.
Five Fixes, One API: Cleaning Up the Mail Pieces Endpoint
Five independent improvements to the mail pieces API: date validation, schema cleanup, cache strategy overhaul, admin UI, and a pricing fallback correction.
When "How Many Paying Customers?" Has Five Different Answers
Building subscription reports that agree with each other, and why counting paying customers is harder than it should be.
When Stripe Fights Itself: Debugging a Webhook Race Condition
Investigating a Stripe::RateLimitError caused by webhook handlers calling the Stripe API while Stripe is still processing the same object.
Building a Public Mail Pieces API — From Zero to Performance-Tuned
Building a token-authenticated mail pieces API with opt-in cost calculation, COUNT-free pagination, and a database index cleanup that dropped 3 redundant indexes.
When Tests Finally Run: A Cascade of Four Discoveries
Debugging 4 layers of test failures — from PG version skew to a sneaky ActiveRecord getter override that silently breaks denormalization callbacks.
Crew Stack Pre-Selection: Saving Clicks, One Default at a Time
Adding default crew assignments to crew stacks, plus fixing a per-tier calculation bug hiding in the view pages.
Building a Public API Endpoint: Mail Pieces with Cost Estimation
Building a token-authenticated mail pieces API endpoint with cost estimation, JSONB caching, and flat query params for external consumers.
When "Active" Doesn't Mean Active: Hunting a 332-Account Ghost in Subscription Reports
A 332-account discrepancy between our subscription report and HubSpot led to three bugs in how we count "active" accounts — blocklist vs allowlist, nil fallbacks, and stale JSONB snapshots.
Per-Tier Pricing: When Every Package Needs Its Own Brain
Implementing per-tier pricing across a video production quote system, and the three sneaky data plumbing bugs that followed.
Production Triage: Data Axle Timeouts & the 186-Second Retry Death Spiral
Investigating a 33-minute Data Axle outage, uncovering a commented-out timeout, and mapping the blast radius of missing circuit breakers.