diff --git a/Dockerfile b/Dockerfile index 0e7671e..5e4b43d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -42,7 +42,7 @@ WORKDIR /app RUN apk add --no-cache ca-certificates tzdata dcron tini -RUN echo "0 0 * * * /app/mensa-upb-scraper >> /var/log/cron.log 2>&1" \ +RUN echo "0 0/8 * * * /app/mensa-upb-scraper >> /var/log/cron.log 2>&1" \ > /etc/crontabs/root && \ touch /var/log/cron.log diff --git a/scraper/src/refresh.rs b/scraper/src/refresh.rs index ef58cde..9556c86 100644 --- a/scraper/src/refresh.rs +++ b/scraper/src/refresh.rs @@ -33,6 +33,11 @@ pub async fn check_refresh(db: &sqlx::PgPool, date: NaiveDate, canteens: &[Cante return false; } + if date < Utc::now().date_naive() { + tracing::trace!("Not refreshing menu for date {date} as it is in the past"); + return false; + } + let canteens_needing_refresh = match sqlx::query!( r#"SELECT canteen, max(scraped_at) AS "scraped_at!" FROM canteens_scraped WHERE canteen = ANY($1) AND scraped_for = $2 GROUP BY canteen"#, &canteens