Skip to content

Commit

Permalink
feat: update validity check condition, batch size and interval
Browse files Browse the repository at this point in the history
  • Loading branch information
its-felix committed Aug 8, 2024
1 parent bbb105c commit 98ab2e8
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>com.gw2auth</groupId>
<artifactId>oauth2-server</artifactId>
<version>1.78.0</version>
<version>1.79.0</version>
<packaging>jar</packaging>

<parent>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ Gw2AccountApiTokenEntity save(@Param("account_id") UUID accountId,
FROM gw2_account_api_tokens tk
INNER JOIN gw2_accounts acc
ON tk.account_id = acc.account_id AND tk.gw2_account_id = acc.gw2_account_id
WHERE tk.last_valid_time >= :last_valid_time
WHERE ( tk.last_valid_time >= :last_valid_time OR tk.last_valid_check_time = tk.last_valid_time )
AND (tk.last_valid_check_time <= :last_valid_check_time OR acc.last_name_check_time <= :last_name_check_time)
ORDER BY tk.last_valid_check_time
LIMIT :limit
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
public class Gw2AccountApiTokenServiceImpl implements Gw2AccountApiTokenService, Clocked {

private static final Logger LOG = LoggerFactory.getLogger(Gw2AccountApiTokenServiceImpl.class);
private static final int VALIDITY_CHECK_BATCH_SIZE = 50;
private static final int VALIDITY_CHECK_BATCH_SIZE = 20;

private final Duration nameCheckInterval;
private final Duration validCheckInterval;
Expand Down Expand Up @@ -65,7 +65,7 @@ public void updateApiTokensValid(Instant lastValidCheckTime, Collection<Gw2Accou
this.gw2AccountApiTokenRepository.updateApiTokensValid(lastValidCheckTime, updates);
}

@Scheduled(fixedRate = 10L, timeUnit = TimeUnit.MINUTES)
@Scheduled(fixedRate = 1L, timeUnit = TimeUnit.MINUTES)
public void refreshTokenValidityAndAccountName() {
final Instant now = this.clock.instant();
final List<Gw2AccountRefreshEntity> tokensToCheck = this.gw2AccountApiTokenRepository.findAllApplicableForRefresh(
Expand Down

0 comments on commit 98ab2e8

Please sign in to comment.