
Building a Content Cleanup System for Old Videos
Introduction Content accumulates. After months of fetching 25 trending videos from 7 regions every few hours, you end up with thousands of video records. Many become stale, irrelevant, or simply take up database space. Here's the cleanup system I built for ViralVidVault . The Cleanup Pipeline Our cleanup runs as the final step of each cron cycle: <?php class ContentCleaner { private \PDO $db ; private int $maxAgeDays ; private int $minViews ; public function __construct ( \PDO $db , int $maxAgeDays = 90 , int $minViews = 100 , ) { $this -> db = $db ; $this -> maxAgeDays = $maxAgeDays ; $this -> minViews = $minViews ; } public function run (): CleanupReport { $report = new CleanupReport (); // Step 1: Remove videos older than maxAge days $report -> expired = $this -> removeExpired (); // Step 2: Remove low-performing videos older than 30 days $report -> lowPerforming = $this -> removeLowPerforming (); // Step 3: Remove already-flagged stale videos older than 7 days $report -> stale = $t
Continue reading on Dev.to Webdev
Opens in a new tab




