fix removing all past items because of trying to scrape past

This commit is contained in:
Moritz Hölting 2026-01-07 10:14:59 +01:00
parent 975193ff65
commit 146faa015b
2 changed files with 6 additions and 1 deletions

View File

@ -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

View File

@ -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