From 6492f7c1761afc8e0761fd5f3417e6af2c614a22 Mon Sep 17 00:00:00 2001 From: Frank Elsinga Date: Wed, 13 Nov 2024 01:30:15 +0100 Subject: [PATCH] made sure that movies and news don't do stupid stuff around requesting `oldestDateAt` The bug occurs because - `timestamp.Timestamp.GetSeconds()` -> Seconds since the Epoch - `time.Time.Second()` -> Second since last whole minute => checking if the `oldestDateAt` is empty needs to change accordingly --- server/backend/movie.go | 2 +- server/backend/news.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/server/backend/movie.go b/server/backend/movie.go index ca92af1b..e28794bc 100644 --- a/server/backend/movie.go +++ b/server/backend/movie.go @@ -52,7 +52,7 @@ func (s *CampusServer) getMovies(ctx context.Context, lastID int32, oldestDateAt tx := s.db.WithContext(ctx). Joins("File"). Order("date ASC") - if oldestDateAt.Second() != 0 || oldestDateAt.Nanosecond() != 0 { + if !oldestDateAt.IsZero() { tx = tx.Where("date > ?", oldestDateAt) } if err := tx.Find(&movies, "kino > ?", lastID).Error; err != nil { diff --git a/server/backend/news.go b/server/backend/news.go index b0ef471b..e3ef036f 100644 --- a/server/backend/news.go +++ b/server/backend/news.go @@ -97,7 +97,7 @@ func (s *CampusServer) getNews(ctx context.Context, sourceID int32, lastNewsID i if sourceID != 0 { tx = tx.Where("src = ?", sourceID) } - if oldestDateAt.Second() != 0 || oldestDateAt.Nanosecond() != 0 { + if !oldestDateAt.IsZero() { tx = tx.Where("date > ?", oldestDateAt) } if lastNewsID != 0 {