Skip to content

Commit bf51b3b

Browse files
committed
feat: give up refreshing lens crendentials after multiple failed attempts
1 parent dc43eb6 commit bf51b3b

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

apps/scheduler/src/services/account-refresh-scheduler.service.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export class AccountRefreshSchedulerService {
1919
this.processInterrupted = true
2020
}
2121

22-
@Interval(1000 * 60 * 30)
22+
@Interval(1000 * 60 * 60 * 3)
2323
async scheduleRefreshAccounts(): Promise<void> {
2424
if (process.env.NODE_ENV !== 'test' && !this.processInterrupted) {
2525
await this.refreshAccounts()
@@ -31,11 +31,17 @@ export class AccountRefreshSchedulerService {
3131
this.logger.log(`Refreshing Lens credentials`)
3232
const fiveDaysAgo = new Date()
3333
fiveDaysAgo.setDate(fiveDaysAgo.getDate() - 5)
34+
const thertyDaysAgo = new Date()
35+
thertyDaysAgo.setDate(thertyDaysAgo.getDate() - 30)
3436

3537
const lensAccount = await this.integrationAccountService.findOne({ key: 'lens' })
3638
const accounts = await this.accountCredentialsService.find({
3739
integrationAccount: lensAccount!._id,
38-
lastCredentialUpdate: { $exists: true, $lte: fiveDaysAgo },
40+
lastCredentialUpdate: {
41+
$exists: true,
42+
$lte: fiveDaysAgo,
43+
$gte: thertyDaysAgo,
44+
},
3945
})
4046
for (const account of accounts) {
4147
try {

0 commit comments

Comments
 (0)