Skip to content

Commit

Permalink
made sure that movies and news don't do stupid stuff around requestin…
Browse files Browse the repository at this point in the history
…g `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
  • Loading branch information
CommanderStorm committed Nov 13, 2024
1 parent 2cdf42e commit 6492f7c
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion server/backend/movie.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion server/backend/news.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 6492f7c

Please sign in to comment.