update, pause
This commit is contained in:
1 parent
e7e4ce7f57
commit
6b5fd8d17f
9 files changed
+53
-27
No files matched your search
@@ -48,10 +48,10 @@ export interface IMonitorService {
|
||||
explain?: boolean;
|
||||
}): Promise<{ summary: any; count: number; monitors: any[] }>;
|
||||
getAllGames(): any;
|
||||
getGroupsByTeamId(args: { teamId: string }): Promise<any[]>;
|
||||
getGroupsByTeamId(args: { teamId: string }): Promise<string[]>;
|
||||
|
||||
// update
|
||||
editMonitor(args: { teamId: string; monitorId: string; body: any }): Promise<void>;
|
||||
editMonitor(args: { teamId: string; monitorId: string; body: Monitor }): Promise<Monitor>;
|
||||
pauseMonitor(args: { teamId: string; monitorId: string }): Promise<any>;
|
||||
|
||||
// delete
|
||||
@@ -423,21 +423,22 @@ export class MonitorService implements IMonitorService {
|
||||
return this.games;
|
||||
};
|
||||
|
||||
getGroupsByTeamId = async ({ teamId }: { teamId: string }): Promise<any[]> => {
|
||||
const groups = await this.db.monitorModule.getGroupsByTeamId({ teamId });
|
||||
getGroupsByTeamId = async ({ teamId }: { teamId: string }): Promise<string[]> => {
|
||||
const groups = await this.monitorsRepository.findGroupsByTeamId(teamId);
|
||||
return groups;
|
||||
};
|
||||
|
||||
editMonitor = async ({ teamId, monitorId, body }: { teamId: string; monitorId: string; body: any }): Promise<void> => {
|
||||
editMonitor = async ({ teamId, monitorId, body }: { teamId: string; monitorId: string; body: Monitor }) => {
|
||||
await this.verifyTeamAccess({ teamId, monitorId });
|
||||
const editedMonitor = await this.db.monitorModule.editMonitor({ monitorId, body });
|
||||
const editedMonitor = await this.monitorsRepository.updateById(monitorId, body);
|
||||
await this.jobQueue.updateJob(editedMonitor);
|
||||
return editedMonitor;
|
||||
};
|
||||
|
||||
pauseMonitor = async ({ teamId, monitorId }: { teamId: string; monitorId: string }): Promise<any> => {
|
||||
await this.verifyTeamAccess({ teamId, monitorId });
|
||||
const monitor = await this.db.monitorModule.pauseMonitor({ monitorId });
|
||||
monitor.isActive === true ? await this.jobQueue.resumeJob(monitor._id, monitor) : await this.jobQueue.pauseJob(monitor);
|
||||
const monitor = await this.monitorsRepository.togglePauseById(monitorId, teamId);
|
||||
monitor.isActive === true ? await this.jobQueue.resumeJob(monitor) : await this.jobQueue.pauseJob(monitor);
|
||||
return monitor;
|
||||
};
|
||||
|
||||
|
||||
@@ -195,7 +195,7 @@ class StatusService {
|
||||
|
||||
// Return early if not enough data points
|
||||
if (monitor.statusWindow.length < monitor.statusWindowSize) {
|
||||
const updated = await this.monitorsRepository.update(monitor.id, monitor);
|
||||
const updated = await this.monitorsRepository.updateById(monitor.id, monitor);
|
||||
return {
|
||||
monitor: updated,
|
||||
statusChanged: false,
|
||||
@@ -285,7 +285,7 @@ class StatusService {
|
||||
}
|
||||
|
||||
monitor.status = newStatus;
|
||||
const updated = await this.monitorsRepository.update(monitor.id, monitor);
|
||||
const updated = await this.monitorsRepository.updateById(monitor.id, monitor);
|
||||
|
||||
return {
|
||||
monitor: updated,
|
||||
|
||||
Reference in new issue
Block a user