rename interface
This commit is contained in:
1 parent
1d4e9d6806
commit
705ecf41c2
3 files changed
+7
-9
No files matched your search
@@ -1,7 +1,7 @@
|
||||
import type { GeoCheck, GroupedGeoCheck } from "@/types/geoCheck.js";
|
||||
|
||||
export interface IGeoChecksRepository {
|
||||
create(geoChecks: Omit<GeoCheck, "id" | "__v" | "createdAt" | "updatedAt">[]): Promise<GeoCheck[]>;
|
||||
createGeoChecks(geoChecks: Omit<GeoCheck, "id" | "__v" | "createdAt" | "updatedAt">[]): Promise<GeoCheck[]>;
|
||||
findByMonitorIdAndDateRange(monitorId: string, startDate: Date, endDate: Date): Promise<GeoCheck[]>;
|
||||
findGroupedByMonitorIdAndDateRange(monitorId: string, startDate: Date, endDate: Date, dateFormat: string): Promise<GroupedGeoCheck[]>;
|
||||
deleteByMonitorId(monitorId: string): Promise<number>;
|
||||
|
||||
@@ -72,7 +72,7 @@ class MongoGeoChecksRepository implements IGeoChecksRepository {
|
||||
};
|
||||
};
|
||||
|
||||
create = async (geoChecks: Omit<GeoCheck, "id" | "__v" | "createdAt" | "updatedAt">[]): Promise<GeoCheck[]> => {
|
||||
createGeoChecks = async (geoChecks: Omit<GeoCheck, "id" | "__v" | "createdAt" | "updatedAt">[]): Promise<GeoCheck[]> => {
|
||||
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;
|
||||
|
||||
@@ -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);
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user