From 4d9e5821a8b3fb28bdb0664dbd93ed748f8e72a2 Mon Sep 17 00:00:00 2001 From: Alex Holliday Date: Mon, 20 Jul 2026 10:21:43 -0700 Subject: [PATCH] purge unused groups route, update tests --- server/src/api/controllers/monitorController.ts | 11 ----------- server/src/api/routes/monitorRoute.ts | 1 - .../domain/monitors/monitor.repository.interface.ts | 1 - .../src/domain/monitors/monitor.repository.mongo.ts | 8 -------- server/src/domain/monitors/monitor.service.ts | 5 ----- server/test/helpers/InMemoryMonitorsRepository.ts | 4 ---- server/test/unit/services/monitorService.test.ts | 13 ------------- 7 files changed, 43 deletions(-) diff --git a/server/src/api/controllers/monitorController.ts b/server/src/api/controllers/monitorController.ts index e0f820a62..2ffb18802 100644 --- a/server/src/api/controllers/monitorController.ts +++ b/server/src/api/controllers/monitorController.ts @@ -44,7 +44,6 @@ export interface IMonitorController { getMonitorsWithChecksByTeamId: RequestHandler; exportMonitorsToJSON: RequestHandler; getAllGames: RequestHandler; - getGroupsByTeamId: RequestHandler; updateNotifications: RequestHandler; } class MonitorController implements IMonitorController { @@ -365,16 +364,6 @@ class MonitorController implements IMonitorController { }); }); - getGroupsByTeamId = catchAsync(async (req: Request, res: Response) => { - const teamId = requireTeamId(req.user?.teamId); - const groups = await this.monitorService.getGroupsByTeamId({ teamId }); - - return res.status(200).json({ - msg: "Groups retrieved successfully", - data: groups, - }); - }); - updateNotifications = catchAsync(async (req: Request, res: Response) => { updateNotificationsValidation.parse(req.body); diff --git a/server/src/api/routes/monitorRoute.ts b/server/src/api/routes/monitorRoute.ts index 29834ce70..74a00637d 100644 --- a/server/src/api/routes/monitorRoute.ts +++ b/server/src/api/routes/monitorRoute.ts @@ -15,7 +15,6 @@ class MonitorRoutes { // Team routes this.router.get("/team", this.monitorController.getMonitorsByTeamId); this.router.get("/team/with-checks", this.monitorController.getMonitorsWithChecksByTeamId); - this.router.get("/team/groups", this.monitorController.getGroupsByTeamId); // Uptime routes this.router.get("/uptime/details/:monitorId", this.monitorController.getUptimeDetailsById); diff --git a/server/src/domain/monitors/monitor.repository.interface.ts b/server/src/domain/monitors/monitor.repository.interface.ts index 46f3df396..a710e366f 100644 --- a/server/src/domain/monitors/monitor.repository.interface.ts +++ b/server/src/domain/monitors/monitor.repository.interface.ts @@ -55,7 +55,6 @@ export interface IMonitorsRepository { // other findMonitorsSummaryByTeamId(teamId: string, config?: SummaryConfig): Promise; - findGroupsByTeamId(teamId: string): Promise; removeNotificationFromMonitors(notificationId: string): Promise; removeTagFromMonitors(tagId: string): Promise; updateNotifications(teamId: string, monitorIds: string[], notificationIds: string[], action: "add" | "remove" | "set"): Promise; diff --git a/server/src/domain/monitors/monitor.repository.mongo.ts b/server/src/domain/monitors/monitor.repository.mongo.ts index 28e4513f2..96db34c15 100644 --- a/server/src/domain/monitors/monitor.repository.mongo.ts +++ b/server/src/domain/monitors/monitor.repository.mongo.ts @@ -382,14 +382,6 @@ class MongoMonitorsRepository implements IMonitorsRepository { ); }; - findGroupsByTeamId = async (teamId: string): Promise => { - const groups = await MonitorModel.distinct("group", { - teamId: new mongoose.Types.ObjectId(teamId), - group: { $nin: [null, ""] }, - }); - return groups.sort(); - }; - removeNotificationFromMonitors = async (notificationId: string): Promise => { await MonitorModel.updateMany({ notifications: notificationId }, { $pull: { notifications: notificationId } }); }; diff --git a/server/src/domain/monitors/monitor.service.ts b/server/src/domain/monitors/monitor.service.ts index 1402cc453..66684c2ac 100644 --- a/server/src/domain/monitors/monitor.service.ts +++ b/server/src/domain/monitors/monitor.service.ts @@ -72,7 +72,6 @@ export interface IMonitorService { order?: "asc" | "desc"; }): Promise; getAllGames(): GamesMap; - getGroupsByTeamId(args: { teamId: string }): Promise; // update editMonitor(args: { teamId: string; monitorId: string; body: Partial }): Promise; @@ -422,10 +421,6 @@ export class MonitorService implements IMonitorService { return this.games; }; - getGroupsByTeamId = async ({ teamId }: { teamId: string }): Promise => { - return await this.monitorsRepository.findGroupsByTeamId(teamId); - }; - editMonitor = async ({ teamId, monitorId, body }: { teamId: string; monitorId: string; body: Partial }) => { const editedMonitor = await this.monitorsRepository.updateById(monitorId, teamId, body); await this.scheduler.updateJob(editedMonitor); diff --git a/server/test/helpers/InMemoryMonitorsRepository.ts b/server/test/helpers/InMemoryMonitorsRepository.ts index 45db5b3f7..09162cfd2 100644 --- a/server/test/helpers/InMemoryMonitorsRepository.ts +++ b/server/test/helpers/InMemoryMonitorsRepository.ts @@ -119,10 +119,6 @@ export class InMemoryMonitorsRepository implements IMonitorsRepository { throw new Error("Not implemented"); } - async findGroupsByTeamId(_teamId: string): Promise { - throw new Error("Not implemented"); - } - async removeNotificationFromMonitors(_notificationId: string): Promise { throw new Error("Not implemented"); } diff --git a/server/test/unit/services/monitorService.test.ts b/server/test/unit/services/monitorService.test.ts index 65d6923a6..6a1cf8343 100644 --- a/server/test/unit/services/monitorService.test.ts +++ b/server/test/unit/services/monitorService.test.ts @@ -18,7 +18,6 @@ const createMonitorsRepositoryMock = () => findByIds: jest.fn(), findMonitorCountByTeamIdAndType: jest.fn(), findMonitorsSummaryByTeamId: jest.fn(), - findGroupsByTeamId: jest.fn(), updateById: jest.fn(), updateNotifications: jest.fn(), togglePauseById: jest.fn(), @@ -746,18 +745,6 @@ describe("MonitorService", () => { }); }); - describe("getGroupsByTeamId", () => { - it("delegates to repository", async () => { - const monitorsRepository = createMonitorsRepositoryMock(); - (monitorsRepository.findGroupsByTeamId as jest.Mock).mockResolvedValue(["group1", "group2"]); - const { service } = createService({ monitorsRepository }); - - const result = await service.getGroupsByTeamId({ teamId: TEAM_ID }); - expect(result).toEqual(["group1", "group2"]); - expect(monitorsRepository.findGroupsByTeamId).toHaveBeenCalledWith(TEAM_ID); - }); - }); - describe("editMonitor", () => { it("updates monitor and refreshes job", async () => { const monitorsRepository = createMonitorsRepositoryMock();