style(api): apply prettier formatting
This commit is contained in:
1 parent
80fef25af3
commit
96fede9fe5
75 files changed
+955
-674
No files matched your search
@@ -8,7 +8,11 @@ import { RiotJobWorkerService } from './riot-job-worker.service';
|
||||
import { RiotRefreshGateway } from './riot-refresh.gateway';
|
||||
|
||||
@Module({
|
||||
imports: [RiotModule, LegacyImportModule, forwardRef(() => TournamentResultModule)],
|
||||
imports: [
|
||||
RiotModule,
|
||||
LegacyImportModule,
|
||||
forwardRef(() => TournamentResultModule),
|
||||
],
|
||||
controllers: [RiotJobQueueController],
|
||||
providers: [RiotJobQueueService, RiotJobWorkerService, RiotRefreshGateway],
|
||||
exports: [RiotJobQueueService],
|
||||
|
||||
@@ -95,7 +95,8 @@ export class RiotJobQueueService {
|
||||
jobId: existingJobId,
|
||||
queueGroup,
|
||||
alreadyQueued: true,
|
||||
etaSeconds: existingStatus?.etaSeconds ?? queuePosition * RIOT_JOB_AVG_SECONDS,
|
||||
etaSeconds:
|
||||
existingStatus?.etaSeconds ?? queuePosition * RIOT_JOB_AVG_SECONDS,
|
||||
queuePosition: existingStatus?.queuePosition ?? queuePosition,
|
||||
});
|
||||
continue;
|
||||
@@ -127,7 +128,8 @@ export class RiotJobQueueService {
|
||||
jobId,
|
||||
queueGroup,
|
||||
alreadyQueued: true,
|
||||
etaSeconds: status?.etaSeconds ?? queuePosition * RIOT_JOB_AVG_SECONDS,
|
||||
etaSeconds:
|
||||
status?.etaSeconds ?? queuePosition * RIOT_JOB_AVG_SECONDS,
|
||||
queuePosition: status?.queuePosition ?? queuePosition,
|
||||
});
|
||||
continue;
|
||||
@@ -164,7 +166,10 @@ export class RiotJobQueueService {
|
||||
});
|
||||
}
|
||||
|
||||
await this.setParent(parentJobId, subJobs.map((job) => job.jobId));
|
||||
await this.setParent(
|
||||
parentJobId,
|
||||
subJobs.map((job) => job.jobId),
|
||||
);
|
||||
if (params.priority === 'high' && needsNewJob) {
|
||||
await this.markRefreshRequested(context.user._id, context.account.puuid);
|
||||
}
|
||||
@@ -253,8 +258,8 @@ export class RiotJobQueueService {
|
||||
const subJobs = (
|
||||
await Promise.all(jobIds.map((jobId) => this.getStatus(jobId)))
|
||||
).filter((status): status is RiotJobStatus => Boolean(status));
|
||||
const done = subJobs.filter((job) =>
|
||||
job.state === 'completed' || job.state === 'failed',
|
||||
const done = subJobs.filter(
|
||||
(job) => job.state === 'completed' || job.state === 'failed',
|
||||
).length;
|
||||
const state = this.resolveParentState(subJobs);
|
||||
|
||||
@@ -411,12 +416,14 @@ export class RiotJobQueueService {
|
||||
job: PollTournamentResultJob,
|
||||
deferUntilMs: number,
|
||||
): Promise<void> {
|
||||
await this.redisService.raw().sendCommand([
|
||||
'ZADD',
|
||||
RIOT_JOB_SCHEDULED_ZSET,
|
||||
String(deferUntilMs),
|
||||
JSON.stringify(job),
|
||||
]);
|
||||
await this.redisService
|
||||
.raw()
|
||||
.sendCommand([
|
||||
'ZADD',
|
||||
RIOT_JOB_SCHEDULED_ZSET,
|
||||
String(deferUntilMs),
|
||||
JSON.stringify(job),
|
||||
]);
|
||||
}
|
||||
|
||||
private parseScheduledJob(value: string): PollTournamentResultJob | null {
|
||||
@@ -449,7 +456,10 @@ export class RiotJobQueueService {
|
||||
);
|
||||
}
|
||||
|
||||
private async setParent(parentJobId: string, jobIds: string[]): Promise<void> {
|
||||
private async setParent(
|
||||
parentJobId: string,
|
||||
jobIds: string[],
|
||||
): Promise<void> {
|
||||
await this.redisService.setJson(
|
||||
this.parentKey(parentJobId),
|
||||
jobIds,
|
||||
|
||||
@@ -1,7 +1,4 @@
|
||||
import type {
|
||||
RiotPlatformRoute,
|
||||
RiotRegionalRoute,
|
||||
} from '../riot/riot.types';
|
||||
import type { RiotPlatformRoute, RiotRegionalRoute } from '../riot/riot.types';
|
||||
import type { RiotQueueGroup } from '../riot/riot-queue.constants';
|
||||
import type { PollTournamentResultJob } from '../tournament-result/tournament-result.types';
|
||||
import type { LegacyImportMemberJob } from '../legacy-import/legacy-import.types';
|
||||
|
||||
@@ -21,14 +21,16 @@ function makeWorker() {
|
||||
deleteStreamEntries: jest.fn().mockResolvedValue(undefined),
|
||||
} as unknown as jest.Mocked<RedisService>;
|
||||
const distributedLockService = {
|
||||
runWithRenewedLock: jest.fn().mockImplementation(async (options, operation) =>
|
||||
operation({
|
||||
lockKey: options.lockKey,
|
||||
lockOwnershipToken: 'lock-owner',
|
||||
lockExpirationDurationMilliseconds:
|
||||
options.lockExpirationDurationMilliseconds,
|
||||
}),
|
||||
),
|
||||
runWithRenewedLock: jest
|
||||
.fn()
|
||||
.mockImplementation(async (options, operation) =>
|
||||
operation({
|
||||
lockKey: options.lockKey,
|
||||
lockOwnershipToken: 'lock-owner',
|
||||
lockExpirationDurationMilliseconds:
|
||||
options.lockExpirationDurationMilliseconds,
|
||||
}),
|
||||
),
|
||||
} as unknown as jest.Mocked<DistributedLockService>;
|
||||
const jobQueueService = {
|
||||
markProcessing: jest.fn().mockResolvedValue(undefined),
|
||||
|
||||
@@ -275,10 +275,10 @@ export class RiotJobWorkerService implements OnModuleInit, OnModuleDestroy {
|
||||
): Promise<{ stream: string; message: StreamEntry } | null> {
|
||||
const result = await this.redisService.readGroup(
|
||||
stream,
|
||||
RIOT_JOB_GROUP,
|
||||
this.consumerIdentifier,
|
||||
'>',
|
||||
{ count: 1, blockMs },
|
||||
RIOT_JOB_GROUP,
|
||||
this.consumerIdentifier,
|
||||
'>',
|
||||
{ count: 1, blockMs },
|
||||
);
|
||||
const message = result?.[0]?.messages[0];
|
||||
return message ? { stream, message } : null;
|
||||
|
||||
@@ -70,7 +70,10 @@ export class RiotRefreshGateway {
|
||||
if (typeof payload?.puuid === 'string' && payload.puuid.trim()) {
|
||||
rooms.push(`puuid:${payload.puuid.trim()}`);
|
||||
}
|
||||
if (typeof payload?.parentJobId === 'string' && payload.parentJobId.trim()) {
|
||||
if (
|
||||
typeof payload?.parentJobId === 'string' &&
|
||||
payload.parentJobId.trim()
|
||||
) {
|
||||
rooms.push(`parent:${payload.parentJobId.trim()}`);
|
||||
}
|
||||
return rooms;
|
||||
|
||||
Reference in new issue
Block a user