diff --git a/src/components/metric/controllers/metric.controller.ts b/src/components/metric/controllers/metric.controller.ts index 0a9170f2..7dc30af8 100644 --- a/src/components/metric/controllers/metric.controller.ts +++ b/src/components/metric/controllers/metric.controller.ts @@ -47,6 +47,7 @@ export class MetricController { query.min, query.max, query.rangeType, + query.step, query.coinId, ); diff --git a/src/components/metric/dtos/cw20-metric-params.dto.ts b/src/components/metric/dtos/cw20-metric-params.dto.ts index 5bfd029b..6f89da9c 100644 --- a/src/components/metric/dtos/cw20-metric-params.dto.ts +++ b/src/components/metric/dtos/cw20-metric-params.dto.ts @@ -15,6 +15,10 @@ export class Cw20MetricParamsDto { @ApiProperty() readonly rangeType: RangeType = RangeType.minute; + @ApiPropertyOptional() + @Transform(({ value }) => Number(value)) + step: number; + @ApiProperty() @IsNotEmpty() coinId: string; diff --git a/src/components/metric/services/metric.service.ts b/src/components/metric/services/metric.service.ts index 5f5baa25..e6448b51 100644 --- a/src/components/metric/services/metric.service.ts +++ b/src/components/metric/services/metric.service.ts @@ -36,13 +36,13 @@ export class MetricService { min: number, max: number, rangeType: RangeType, + step: number, coinId: string, ): Promise { try { this.logger.log(ctx, `${this.getTokenInfo.name} was called!`); // const { step, fluxType, amount } = buildCondition(range); - const range = rangeType === RangeType.minute ? 3 : 1; - const queryStep = `${range}${rangeType}`; + const queryStep = `${step || 1}${rangeType}`; const minDate = new Date(min), maxDate = new Date(max); @@ -162,7 +162,7 @@ export class MetricService { const compareDate = moment(maxDate).utc(); switch (rangeType) { case RangeType.day: - compareDate.add(-365, 'd'); // Value of 1 year + compareDate.add(-730, 'd'); // Value of 2 years formatDate = 'YYYY-MM-DDT00:00:00.000'; break; case RangeType.month: @@ -170,11 +170,11 @@ export class MetricService { formatDate = 'YYYY-MM-01T00:00:00.000'; break; case RangeType.hour: - compareDate.add(-360, 'h'); // Value of 15 day + compareDate.add(-1440, 'h'); // Value of 60 days formatDate = 'YYYY-MM-DDTHH:00:00.000'; break; default: - compareDate.add(-1440, 'm'); // Value of 24 hourse + compareDate.add(-2880, 'm'); // Value of 48 hours formatDate = 'YYYY-MM-DDTHH:mm:00.000'; break; } diff --git a/src/components/soulbound-token/controllers/soulbound-token.controller.ts b/src/components/soulbound-token/controllers/soulbound-token.controller.ts index ec308d91..570b1fb6 100644 --- a/src/components/soulbound-token/controllers/soulbound-token.controller.ts +++ b/src/components/soulbound-token/controllers/soulbound-token.controller.ts @@ -223,4 +223,20 @@ export class SoulboundTokenController { minterAddress, ); } + + @Get('count/:receiverAddress') + async countTokenByReceiverAddress( + @ReqContext() ctx: RequestContext, + @Param('receiverAddress') receiverAddress: string, + ) { + this.logger.log( + ctx, + `${this.countTokenByReceiverAddress.name} was called!`, + ); + const token = await this.soulboundTokenService.countTokenByReceiverAddress( + ctx, + receiverAddress, + ); + return { data: token }; + } } diff --git a/src/components/soulbound-token/services/soulbound-token.service.ts b/src/components/soulbound-token/services/soulbound-token.service.ts index 12aea394..d4f74e78 100644 --- a/src/components/soulbound-token/services/soulbound-token.service.ts +++ b/src/components/soulbound-token/services/soulbound-token.service.ts @@ -35,6 +35,7 @@ import { RedisUtil } from '../../../shared/utils/redis.util'; import { SoulboundWhiteListRepository } from '../repositories/soulbound-white-list.repository'; import { TokenUpdatedParasDto } from '../dtos/token-updated-paras.dto'; import { SoulboundRejectListRepository } from '../repositories/soulbound-reject-list.repository'; +import { Not } from 'typeorm'; @Injectable() export class SoulboundTokenService { @@ -423,6 +424,29 @@ export class SoulboundTokenService { return { notify: result }; } + /** + * count soulbound token of receiver address + * @param ctx + * @param receiverAddress + * @returns + */ + async countTokenByReceiverAddress( + ctx: RequestContext, + receiverAddress: string, + ) { + this.logger.log( + ctx, + `============== ${this.countTokenByReceiverAddress.name} was called with paras: ${receiverAddress}! ==============`, + ); + const result = await this.soulboundTokenRepos.count({ + where: { + receiver_address: receiverAddress, + status: Not(SOULBOUND_TOKEN_STATUS.REJECTED), + }, + }); + return result; + } + /** * Update notify of soulbound token * @param ctx diff --git a/src/shared/configs/configuration.ts b/src/shared/configs/configuration.ts index fbb729cd..cce6db81 100644 --- a/src/shared/configs/configuration.ts +++ b/src/shared/configs/configuration.ts @@ -37,7 +37,6 @@ export default () => ({ channel: process.env.REDIS_ABT_CHANNEL, }, }, - threads: process.env.THREADS, indexer: { url: process.env.INDEXER_URL, chainId: process.env.INDEXER_CHAIN_ID,