#!/bin/sh
# 消化積壓 jobs（一次性 queue:work）
cd /www/wwwroot/faithfulness
sudo -u www /usr/bin/php artisan queue:work --stop-when-empty --max-time=3000 --tries=1 2>&1 | tail -5
echo "=== after work ==="
sudo -u www /usr/bin/php artisan tinker --execute="
echo 'pending jobs: '.DB::table('jobs')->count().PHP_EOL;
echo 'failed jobs: '.DB::table('failed_jobs')->count().PHP_EOL;
echo 'route cache rows: '.DB::table('location_route_caches')->count().PHP_EOL;
echo 'geocoded branches: '.DB::table('branches')->whereNotNull('lat')->count().'/'.DB::table('branches')->count().PHP_EOL;
echo 'geocoded dorms: '.DB::table('dormitories')->whereNotNull('lat')->count().'/'.DB::table('dormitories')->count().PHP_EOL;
" 2>&1 | grep -E "pending|failed|rows|geocoded"
