diff --git a/server/src/repositories/geo-checks/IGeoChecksRepository.ts b/server/src/repositories/geo-checks/IGeoChecksRepository.ts index e0ee96e36..9cba699ec 100644 --- a/server/src/repositories/geo-checks/IGeoChecksRepository.ts +++ b/server/src/repositories/geo-checks/IGeoChecksRepository.ts @@ -1,7 +1,7 @@ import type { GeoCheck, GroupedGeoCheck } from "@/types/geoCheck.js"; export interface IGeoChecksRepository { - create(geoChecks: Omit[]): Promise; + createGeoChecks(geoChecks: Omit[]): Promise; findByMonitorIdAndDateRange(monitorId: string, startDate: Date, endDate: Date): Promise; findGroupedByMonitorIdAndDateRange(monitorId: string, startDate: Date, endDate: Date, dateFormat: string): Promise; deleteByMonitorId(monitorId: string): Promise; diff --git a/server/src/repositories/geo-checks/MongoGeoChecksRepository.ts b/server/src/repositories/geo-checks/MongoGeoChecksRepository.ts index 8717eb173..539f9addf 100644 --- a/server/src/repositories/geo-checks/MongoGeoChecksRepository.ts +++ b/server/src/repositories/geo-checks/MongoGeoChecksRepository.ts @@ -72,7 +72,7 @@ class MongoGeoChecksRepository implements IGeoChecksRepository { }; }; - create = async (geoChecks: Omit[]): Promise => { + createGeoChecks = async (geoChecks: Omit[]): Promise => { try { const docs = await GeoCheckModel.insertMany( geoChecks.map((geoCheck) => ({ @@ -88,9 +88,9 @@ class MongoGeoChecksRepository implements IGeoChecksRepository { return docs.map((doc) => this.toEntity(doc)); } catch (error: any) { this.logger.error({ - message: `Failed to create geo checks: ${error.message}`, + message: `Failed to createGeoChecks: ${error.message}`, service: SERVICE_NAME, - method: "create", + method: "createGeoChecks", stack: error.stack, }); throw error; diff --git a/server/src/service/business/geoChecksService.ts b/server/src/service/business/geoChecksService.ts index 0ffa84150..351943143 100644 --- a/server/src/service/business/geoChecksService.ts +++ b/server/src/service/business/geoChecksService.ts @@ -1,4 +1,5 @@ import type { Monitor, GeoCheck } from "@/types/index.js"; +import type { GeoCheckResult } from "@/types/geoCheck.js"; import { Types } from "mongoose"; import type { IGeoChecksRepository } from "@/repositories/index.js"; import type { IGlobalPingService } from "@/service/infrastructure/globalPingService.js"; @@ -123,7 +124,7 @@ class GeoChecksService implements IGeoChecksService { } } - private buildGeoCheck(monitor: Monitor, results: any[]): GeoCheck { + private buildGeoCheck(monitor: Monitor, results: GeoCheckResult[]): GeoCheck { const now = new Date(); const expiryDate = new Date(now.getTime() + this.TTL_DAYS * 24 * 60 * 60 * 1000); @@ -142,11 +143,8 @@ class GeoChecksService implements IGeoChecksService { }; } - /** - * Create geo checks (called by buffer service) - */ createGeoChecks = async (geoChecks: GeoCheck[]) => { - return this.geoChecksRepository.create(geoChecks); + return this.geoChecksRepository.createGeoChecks(geoChecks); }; }