2 Commits

Author SHA1 Message Date
d888ab1eb5 Merge remote-tracking branch 'origin/master'
Some checks failed
Deploy API / docker (17, 3.8.5) (push) Failing after 1m21s
2024-08-09 00:52:04 +01:00
8371344a7d change account refresh interval 2024-08-09 00:51:36 +01:00

View File

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