Scott Robinson Technical Lead

Internal tools

Rebuilding dor.ky

Statamic on MySQL, with four importers keeping the site current on its own

This site runs on Statamic with every piece of content in MySQL rather than flat files, and four importers keeping the moving parts current: Strava activities, parkrun results, Packagist download counts and Goodreads shelves. ## Why the database The flat file default is the reason most people pick Statamic, and it is the right call for a site one person edits from one machine. It stopped being the right call here the moment scheduled importers started writing content: a cron job writing YAML into a git working copy is a merge conflict waiting for a deploy to collide with it. Moving entries, users, taxonomies and globals to the Eloquent driver made writes ordinary. An importer inserts a row, the site reads it, and a deploy touches neither. ## What the importers do Each one is a self contained addon: its own migration, model, command and Antlers tag, scheduled from its own service provider. They share nothing but a notifier. The Strava one is the awkward one, because Strava's activity list returns a summary and the interesting parts live one request deeper. It works a queue of fifty a run, newest first, so a new activity is detailed within the hour while nineteen hundred historical ones fill in behind it at whatever the daily quota allows. ## The part worth stealing Every importer stops cleanly when it hits a rate limit and exits successfully. A quota stop is the thing pacing itself, not a failure, and treating it as an error would have meant an alert every hour until the window rolled over. That distinction, between a job that failed and a job that is waiting, is most of what makes scheduled work quiet enough to leave alone.