From 1d87b158fd681c10276ab868624fa2fc2712c925 Mon Sep 17 00:00:00 2001 From: Kenneth Hoang Date: Tue, 7 Jan 2025 16:17:13 +0700 Subject: [PATCH 1/2] feat: job priority --- src/constants/queue.constant.ts | 6 ++++++ src/modules/crawler/deploy-token.ts | 10 ++++++++-- src/modules/crawler/job-unlock.provider.ts | 8 +++++++- 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/src/constants/queue.constant.ts b/src/constants/queue.constant.ts index a798719..902d627 100644 --- a/src/constants/queue.constant.ts +++ b/src/constants/queue.constant.ts @@ -5,3 +5,9 @@ export enum EQueueName { } export const getEvmValidatorQueueName = (index: number) => `EVM_VALIDATOR_${index}`; export const getMinaValidatorQueueName = (index: number) => `MINA_VALIDATOR_${index}`; + +// job priority, lower index is higher priority +export enum EJobPriority { + DEPLOY_TOKEN, + UNLOCK, +} diff --git a/src/modules/crawler/deploy-token.ts b/src/modules/crawler/deploy-token.ts index 3c5263f..f3872e1 100644 --- a/src/modules/crawler/deploy-token.ts +++ b/src/modules/crawler/deploy-token.ts @@ -7,7 +7,7 @@ import { IsNull } from 'typeorm'; import { ETokenPairStatus } from '../../constants/blockchain.constant.js'; import { EEnvKey } from '../../constants/env.constant.js'; -import { EQueueName } from '../../constants/queue.constant.js'; +import { EJobPriority, EQueueName } from '../../constants/queue.constant.js'; import { CommonConfigRepository } from '../../database/repositories/common-configuration.repository.js'; import { LoggerService } from '../../shared/modules/logger/logger.service.js'; import { QueueService } from '../../shared/modules/queue/queue.service.js'; @@ -148,6 +148,7 @@ export class TokenDeployer { jobId: `deploy-token-${tokenPairId}`, removeOnComplete: true, removeOnFail: true, + priority: EJobPriority.DEPLOY_TOKEN, }, ); } @@ -160,7 +161,12 @@ export class TokenDeployer { tokenPairId, }, }, - { jobId: `deploy-token-${tokenPairId}`, removeOnComplete: true, removeOnFail: true }, + { + jobId: `deploy-token-${tokenPairId}`, + removeOnComplete: true, + removeOnFail: true, + priority: EJobPriority.DEPLOY_TOKEN, + }, ); } } diff --git a/src/modules/crawler/job-unlock.provider.ts b/src/modules/crawler/job-unlock.provider.ts index dc6d150..f8a4515 100644 --- a/src/modules/crawler/job-unlock.provider.ts +++ b/src/modules/crawler/job-unlock.provider.ts @@ -7,7 +7,12 @@ import { QueryDeepPartialEntity } from 'typeorm/query-builder/QueryPartialEntity import { ENetworkName } from '../../constants/blockchain.constant.js'; import { EEnvKey } from '../../constants/env.constant.js'; -import { EQueueName, getEvmValidatorQueueName, getMinaValidatorQueueName } from '../../constants/queue.constant.js'; +import { + EJobPriority, + EQueueName, + getEvmValidatorQueueName, + getMinaValidatorQueueName, +} from '../../constants/queue.constant.js'; import { CommonConfigRepository } from '../../database/repositories/common-configuration.repository.js'; import { EventLogRepository } from '../../database/repositories/event-log.repository.js'; import { LoggerService } from '../../shared/modules/logger/logger.service.js'; @@ -188,6 +193,7 @@ export class JobUnlockProvider { jobId: `send-unlock-${data.eventLogId}`, removeOnComplete: true, removeOnFail: true, + priority: EJobPriority.UNLOCK, }, ); } From f6271f3641adf79dd50c34121fae0516cb67ec50 Mon Sep 17 00:00:00 2001 From: Kenneth Hoang Date: Tue, 7 Jan 2025 16:18:05 +0700 Subject: [PATCH 2/2] feat: default value token visibility --- src/modules/users/admin.service.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/modules/users/admin.service.ts b/src/modules/users/admin.service.ts index 50a9eea..cbf316b 100644 --- a/src/modules/users/admin.service.ts +++ b/src/modules/users/admin.service.ts @@ -40,6 +40,7 @@ export class AdminService { newCommonConfig.mintingFee = payload.mintingFee; newCommonConfig.unlockingFee = payload.unlockingFee; newCommonConfig.status = ETokenPairStatus.CREATED; + newCommonConfig.isHidden = true; return newCommonConfig.save(); }); assert(isNumber(newTokenPair.id), 'Token pair invalid!');