Skip to content

Commit

Permalink
Ignore activity dates in the future
Browse files Browse the repository at this point in the history
  • Loading branch information
Rakambda committed Oct 15, 2024
1 parent 04f909e commit bc846a3
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,9 @@ private Stream<AnilistEntity> processUser(@NotNull JDA jda, @NotNull AnilistEnti
return Stream.empty();
}

var lastMediaListDate = entity.getLastMediaListDate();
var lastMediaListDate = Optional.ofNullable(entity.getLastMediaListDate())
.filter(i -> i.isBefore(Instant.now()))
.orElse(null);
var mediaLists = anilistService.getAllMediaList(user.getIdLong(), entity.getUserId()).stream()
.filter(e -> isNewer(e, lastMediaListDate))
.sorted(Comparator.comparing(e -> extractDate(e).orElse(Instant.EPOCH)))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,9 @@ private Stream<AnilistEntity> processUser(@NotNull JDA jda, @NotNull AnilistEnti
return Stream.empty();
}

var lastNotificationDate = entity.getLastNotificationDate();
var lastNotificationDate = Optional.ofNullable(entity.getLastNotificationDate())
.filter(i -> i.isBefore(Instant.now()))
.orElse(null);
var notifications = anilistService.getAllNotifications(user.getIdLong(), NOTIFICATION_TYPES, true).stream()
.filter(e -> isNewer(e, lastNotificationDate))
.sorted(Comparator.comparing(e -> extractDate(e).orElse(Instant.EPOCH)))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,9 @@ private Stream<SimklEntity> processUser(@NotNull JDA jda, @NotNull SimklEntity e
return Stream.empty();
}

var lastActivityDate = entity.getLastActivityDate();
var lastActivityDate = Optional.ofNullable(entity.getLastActivityDate())
.filter(i -> i.isBefore(Instant.now()))
.orElse(null);
var histories = simklService.getAllUserHistory(user.getIdLong(), lastActivityDate).stream()
.filter(h -> isNewer(h, lastActivityDate))
.sorted(USER_HISTORY_COMPARATOR)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package fr.rakambda.rsndiscord.spring.schedule.impl.trakt;

import fr.rakambda.rsndiscord.spring.api.exceptions.NotLoggedInException;
import fr.rakambda.rsndiscord.spring.api.exceptions.RequestFailedException;
import fr.rakambda.rsndiscord.spring.api.themoviedb.TheMovieDbService;
import fr.rakambda.rsndiscord.spring.api.themoviedb.TmdbImageSize;
Expand Down Expand Up @@ -127,7 +126,9 @@ private Stream<TraktEntity> processUser(@NotNull JDA jda, @NotNull TraktEntity e
return Stream.empty();
}

var lastActivityDate = entity.getLastActivityDate();
var lastActivityDate = Optional.ofNullable(entity.getLastActivityDate())
.filter(i -> i.isBefore(Instant.now()))
.orElse(null);
var histories = traktService.getAllUserHistory(user.getIdLong(), lastActivityDate, null).stream()
.filter(h -> isNewer(h, lastActivityDate))
.sorted(USER_HISTORY_COMPARATOR)
Expand Down

0 comments on commit bc846a3

Please sign in to comment.