From 5bfac08ed8d7f407c2c8d9a987166309c34f4726 Mon Sep 17 00:00:00 2001 From: David May <85513542+davidleomay@users.noreply.github.com> Date: Mon, 2 Feb 2026 14:22:23 +0100 Subject: [PATCH] feat: improved auth performance for batch logins (#3108) * feat: improved auth performance for batch logins * fix: pending Olky amounts * fix: format * feat: lower Olky poll frequency --- src/shared/models/ip-log/ip-log.service.ts | 13 +++++ .../fiat-output/fiat-output-job.service.ts | 56 +++++++++---------- 2 files changed, 40 insertions(+), 29 deletions(-) diff --git a/src/shared/models/ip-log/ip-log.service.ts b/src/shared/models/ip-log/ip-log.service.ts index 166653ba34..96aed1d9eb 100644 --- a/src/shared/models/ip-log/ip-log.service.ts +++ b/src/shared/models/ip-log/ip-log.service.ts @@ -23,8 +23,21 @@ export class IpLogService { ) {} private readonly idCache = new AsyncCache(CacheItemResetPeriod.EVERY_6_MONTHS); + private readonly recentLogCache = new AsyncCache(CacheItemResetPeriod.EVERY_10_SECONDS); async create(ip: string, url: string, address: string, walletType?: WalletType, userData?: UserData): Promise { + const cacheKey = `${ip}:${address}:${url}:${walletType ?? ''}:${userData?.id ?? ''}`; + + return this.recentLogCache.get(cacheKey, () => this.doCreate(ip, url, address, walletType, userData)); + } + + private async doCreate( + ip: string, + url: string, + address: string, + walletType?: WalletType, + userData?: UserData, + ): Promise { const { country, result, user } = await this.checkIpCountry(ip, address); const ipLog = this.ipLogRepo.create({ ip, diff --git a/src/subdomains/supporting/fiat-output/fiat-output-job.service.ts b/src/subdomains/supporting/fiat-output/fiat-output-job.service.ts index 2cbc52f6b5..585f67f1ec 100644 --- a/src/subdomains/supporting/fiat-output/fiat-output-job.service.ts +++ b/src/subdomains/supporting/fiat-output/fiat-output-job.service.ts @@ -57,10 +57,35 @@ export class FiatOutputJobService { await this.checkTransmission(); await this.transmitYapealPayments(); await this.transmitOlkypayPayments(); - await this.checkOlkypayOrderStatus(); await this.searchOutgoingBankTx(); } + @DfxCron(CronExpression.EVERY_HOUR, { process: Process.FIAT_OUTPUT }) + async checkOlkypayOrderStatus(): Promise { + if (DisabledProcess(Process.FIAT_OUTPUT_OLKYPAY_STATUS_CHECK)) return; + if (!this.olkypayService.isAvailable()) return; + + const entities = await this.fiatOutputRepo.find({ + where: { + olkyOrderId: Not(IsNull()), + isApprovedDate: IsNull(), + isComplete: false, + }, + }); + + for (const entity of entities) { + try { + const order = await this.olkypayService.getPaymentOrder(+entity.olkyOrderId); + + if (order.orderStatus !== OlkypayOrderStatus.TO_VALIDATE) { + await this.fiatOutputRepo.update(entity.id, { isApprovedDate: new Date() }); + } + } catch (e) { + this.logger.error(`Failed to check OLKYPAY order status for fiat output ${entity.id}:`, e); + } + } + } + @DfxCron(CronExpression.EVERY_HOUR, { process: Process.FIAT_OUTPUT, timeout: 1800 }) async generateReports() { const entities = await this.fiatOutputRepo.find({ @@ -196,9 +221,7 @@ export class FiatOutputJobService { const pendingFiatOutputs = accountIbanGroup.filter( (tx) => - tx.isReadyDate && - !tx.bankTx && - (!tx.bank || ![IbanBankName.YAPEAL, IbanBankName.OLKY].includes(tx.bank.name) || !tx.isTransmittedDate), + tx.isReadyDate && !tx.bankTx && (!tx.bank || tx.bank.name !== IbanBankName.YAPEAL || !tx.isTransmittedDate), ); const pendingBalance = Util.sumObjValue(pendingFiatOutputs, 'bankAmount'); @@ -445,31 +468,6 @@ export class FiatOutputJobService { } } - private async checkOlkypayOrderStatus(): Promise { - if (DisabledProcess(Process.FIAT_OUTPUT_OLKYPAY_STATUS_CHECK)) return; - if (!this.olkypayService.isAvailable()) return; - - const entities = await this.fiatOutputRepo.find({ - where: { - olkyOrderId: Not(IsNull()), - isApprovedDate: IsNull(), - isComplete: false, - }, - }); - - for (const entity of entities) { - try { - const order = await this.olkypayService.getPaymentOrder(+entity.olkyOrderId); - - if (order.orderStatus !== OlkypayOrderStatus.TO_VALIDATE) { - await this.fiatOutputRepo.update(entity.id, { isApprovedDate: new Date() }); - } - } catch (e) { - this.logger.error(`Failed to check OLKYPAY order status for fiat output ${entity.id}:`, e); - } - } - } - private async searchOutgoingBankTx(): Promise { if (DisabledProcess(Process.FIAT_OUTPUT_BANK_TX_SEARCH)) return;