-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #36 from game-node-app/dev
Dev
- Loading branch information
Showing
40 changed files
with
1,411 additions
and
1,421 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
25 changes: 15 additions & 10 deletions
25
src/achievements/achievements-queue/achievements-queue.processor.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,26 @@ | ||
import { Process, Processor } from "@nestjs/bull"; | ||
import { Processor, WorkerHost } from "@nestjs/bullmq"; | ||
import { | ||
ACHIEVEMENTS_QUEUE_NAME, | ||
ACHIEVEMENTS_QUEUE_TRACKING_JOB_NAME, | ||
AchievementsQueueJob, | ||
} from "./achievements-queue.constants"; | ||
import { Job } from "bull"; | ||
import { Job } from "bullmq"; | ||
import { AchievementsService } from "../achievements.service"; | ||
import { WorkerHostProcessor } from "../../utils/WorkerHostProcessor"; | ||
|
||
@Processor(ACHIEVEMENTS_QUEUE_NAME) | ||
export class AchievementsQueueProcessor { | ||
constructor(private readonly achievementsService: AchievementsService) {} | ||
export class AchievementsQueueProcessor extends WorkerHostProcessor { | ||
constructor(private readonly achievementsService: AchievementsService) { | ||
super(); | ||
} | ||
|
||
@Process(ACHIEVEMENTS_QUEUE_TRACKING_JOB_NAME) | ||
async processTrackingJobs(job: Job<AchievementsQueueJob>) { | ||
return this.achievementsService.trackAchievementsProgress( | ||
job.data.targetUserId, | ||
job.data.category, | ||
); | ||
async process(job: Job<AchievementsQueueJob>): Promise<void> { | ||
switch (job.name) { | ||
case ACHIEVEMENTS_QUEUE_TRACKING_JOB_NAME: | ||
return this.achievementsService.trackAchievementsProgress( | ||
job.data.targetUserId, | ||
job.data.category, | ||
); | ||
} | ||
} | ||
} |
3 changes: 1 addition & 2 deletions
3
src/achievements/achievements-queue/achievements-queue.service.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
src/achievements/achievements-queue/achievements-queue.service.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 27 additions & 22 deletions
49
src/activities/activities-queue/activities-queue-processor.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,41 @@ | ||
import { Process, Processor } from "@nestjs/bull"; | ||
import { Processor, WorkerHost } from "@nestjs/bullmq"; | ||
import { Activity } from "../activities-repository/entities/activity.entity"; | ||
import { Job } from "bull"; | ||
import { Job } from "bullmq"; | ||
import { Injectable, Logger } from "@nestjs/common"; | ||
import { ActivitiesRepositoryService } from "../activities-repository/activities-repository.service"; | ||
import { WorkerHostProcessor } from "../../utils/WorkerHostProcessor"; | ||
|
||
@Processor("activities") | ||
@Injectable() | ||
export class ActivitiesQueueProcessor { | ||
private readonly logger = new Logger(ActivitiesQueueProcessor.name); | ||
export class ActivitiesQueueProcessor extends WorkerHostProcessor { | ||
logger = new Logger(ActivitiesQueueProcessor.name); | ||
|
||
constructor( | ||
private activitiesRepositoryService: ActivitiesRepositoryService, | ||
) {} | ||
|
||
@Process("addActivity") | ||
async addActivity(job: Job<Activity>) { | ||
try { | ||
await this.activitiesRepositoryService.create(job.data); | ||
} catch (e) { | ||
this.logger.error("Error while processing activity: ", e); | ||
this.logger.log("This error happened for data: ", job.data); | ||
} | ||
) { | ||
super(); | ||
} | ||
|
||
@Process("deleteActivity") | ||
async removeActivity(job: Job<string>) { | ||
try { | ||
const sourceId = job.data; | ||
await this.activitiesRepositoryService.deleteBySourceId(sourceId); | ||
} catch (e) { | ||
this.logger.error("Error while deleting activity: ", e); | ||
this.logger.log("This error happened for data: ", job.data); | ||
async process(job: Job<Activity | string>) { | ||
if (job.name === "addActivity") { | ||
try { | ||
await this.activitiesRepositoryService.create( | ||
job.data as Activity, | ||
); | ||
} catch (e) { | ||
this.logger.error("Error while processing activity: ", e); | ||
this.logger.log("This error happened for data: ", job.data); | ||
} | ||
} else if (job.name === "deleteActivity") { | ||
try { | ||
const sourceId = job.data; | ||
await this.activitiesRepositoryService.deleteBySourceId( | ||
sourceId as string, | ||
); | ||
} catch (e) { | ||
this.logger.error("Error while deleting activity: ", e); | ||
this.logger.log("This error happened for data: ", job.data); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/activities/activities-queue/activities-queue.service.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.