Skip to content

Commit

Permalink
feat: sync identities in a 10m interval
Browse files Browse the repository at this point in the history
  • Loading branch information
beeman committed Feb 11, 2024
1 parent 80ad3b4 commit 8cede84
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {
@Injectable()
export class ApiNetworkAssetSyncService {
private readonly logger = new Logger(ApiNetworkAssetSyncService.name)
private readonly assetTimeout = 1000 * 60 * 5
private readonly assetTimeout = 1000 * 60 * 10

constructor(
@InjectQueue(API_NETWORK_ASSET_SYNC) private networkAssetSyncQueue: Queue,
Expand All @@ -28,9 +28,9 @@ export class ApiNetworkAssetSyncService {
) {}

async sync(identity: Identity) {
// If the last sync was less than 5 minutes ago, do not sync
// If the last sync was less than 10 minutes ago, do not sync
if ((identity.syncEnded?.getTime() ?? 0) > new Date().getTime() - this.assetTimeout) {
this.logger.log(`Identity ${identity.id} sync skipped, last sync less than 5 minutes ago`)
this.logger.log(`Identity ${identity.id} sync skipped, last sync less than 10 minutes ago`)
return true
}

Expand All @@ -45,7 +45,7 @@ export class ApiNetworkAssetSyncService {
where: {
provider: IdentityProvider.Solana,
OR: [
// Sync if the last sync was more than 5 minutes ago
// Sync if the last sync was more than 10 minutes ago
{ syncEnded: { lt: new Date(new Date().getTime() - this.assetTimeout) } },
{ syncEnded: null },
],
Expand Down

0 comments on commit 8cede84

Please sign in to comment.