Fix NAS stats returning zeros instead of real download numbers

Two independent bugs, either of which made gather_castopod() report
total_downloads: 0 on a dev machine — indistinguishable from a podcast nobody
listens to.

- NAS_SSH hardcoded mmgnas-10g, which is only reachable when the 10G cable is
  physically connected. Now probed once per process with a 2s timeout and
  falls back to mmgnas; NAS_HOST overrides detection entirely. Same detection
  added to deploy_stats_cron.sh.
- _run_db_query treated any docker binary on PATH as "running on the NAS", so
  a machine with Docker Desktop queried its own daemon, found no castopod
  container, and never fell back to SSH. Only the QNAP container-station path
  counts now.

Real figures with both fixed: 3803 downloads, 750 unique listeners.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
2026-08-15 17:05:10 -05:00
co-authored by Claude Opus 5
parent b1ad249e51
commit fe37c037d4
2 changed files with 55 additions and 8 deletions
+13 -1
View File
@@ -5,9 +5,21 @@
set -e
NAS_HOST="mmgnas-10g"
NAS_USER="luke"
NAS_PORT="8001"
# mmgnas-10g is only up when the 10G cable is physically connected. Prefer it
# when reachable (faster transfers), otherwise fall back to the wireless/1G
# host. Override with NAS_HOST=... to skip detection.
if [ -z "$NAS_HOST" ]; then
if ssh -p "$NAS_PORT" -o ConnectTimeout=2 -o BatchMode=yes \
"$NAS_USER@mmgnas-10g" true 2>/dev/null; then
NAS_HOST="mmgnas-10g"
else
NAS_HOST="mmgnas"
fi
echo "NAS host: $NAS_HOST"
fi
DOCKER_BIN="/share/CACHEDEV1_DATA/.qpkg/container-station/bin/docker"
DEPLOY_DIR="/share/CACHEDEV1_DATA/podcast-stats"
CONTAINER_NAME="podcast-stats"