change account refresh interval

This commit is contained in:
Lee 2024-08-09 00:51:36 +01:00
parent 8e3a46f8bc
commit 8371344a7d

@ -28,9 +28,9 @@ import java.util.concurrent.TimeUnit;
@Log4j2(topic = "User Service")
public class UserService {
/**
* The interval to force update the user's account.
* The interval to refresh the user's account data from external services
*/
private static long FORCE_UPDATE_INTERVAL = TimeUnit.HOURS.toMillis(4);
private static long ACCOUNT_REFRESH_INTERVAL = TimeUnit.HOURS.toMillis(1);
/**
* The user repository to use
@ -103,9 +103,9 @@ public class UserService {
// Ensure the users ScoreSaber account is up-to-date
ScoreSaberAccount scoresaberAccount = user.getScoresaberAccount();
if (scoresaberAccount == null || scoresaberAccount.getLastUpdated().before(new Date(System.currentTimeMillis() - FORCE_UPDATE_INTERVAL))) {
if (scoresaberAccount == null || scoresaberAccount.getLastUpdated().before(new Date(System.currentTimeMillis() - ACCOUNT_REFRESH_INTERVAL))) {
try {
log.info("Updating account for '{}', last update: {}",
log.info("[Scoresaber] Updating account for '{}', last update: {}",
steamId,
scoresaberAccount == null ? "now" : TimeUtils.format(System.currentTimeMillis() - scoresaberAccount.getLastUpdated().getTime())
);
@ -118,7 +118,7 @@ public class UserService {
historyToday.setCountryRank(accountToken.getCountryRank());
historyToday.setPp(accountToken.getPp());
} catch (Exception ex) {
log.error("Failed to update ScoreSaber account for '{}'", steamId, ex);
log.error("[Scoresaber] Failed to update account for '{}'", steamId, ex);
}
shouldUpdate = true;
}