fix remaining type issues

This commit is contained in:
Alex Holliday committed 2026-01-05 21:12:28 +00:00
1 parent 9583332852
commit ce568424a3
13 files changed
+108 -40

No files matched your search

@@ -48,7 +48,12 @@ class MongoCheckRepository implements IChecksRepository {
avgResponseTimeDown: doc.avgResponseTimeDown,
totalContainers: doc.totalContainers,
runningContainers: doc.runningContainers,
runningPercent: doc.runningPercent,
healthyContainers: doc.healthyContainers,
healthyPercent: doc.healthyPercent,
runningContainersSnapshot: doc.runningContainersSnapshot,
totalExposedPorts: doc.totalExposedPorts,
uniqueImages: doc.uniqueImages,
accessibility: doc.accessibility,
bestPractices: doc.bestPractices,
seo: doc.seo,
@@ -190,12 +195,53 @@ class MongoCheckRepository implements IChecksRepository {
},
},
},
runningContainersSnapshot: { $last: "$runningContainersSnapshot" },
totalExposedPorts: { $last: "$totalExposedPorts" },
uniqueImages: { $last: "$uniqueImages" },
};
};
private getDockerProjection = (): object => {
const projectStage: any = { status: 1, responseTime: 1, createdAt: 1 };
projectStage["dockerContainers"] = 1;
projectStage["runningContainersSnapshot"] = {
$filter: {
input: { $ifNull: ["$dockerContainers", []] },
as: "c",
cond: { $eq: ["$$c.running", true] },
},
};
projectStage["totalExposedPorts"] = {
$sum: {
$map: {
input: { $ifNull: ["$dockerContainers", []] },
as: "c",
in: { $size: { $ifNull: ["$$c.exposed_ports", []] } },
},
},
};
projectStage["uniqueImages"] = {
$size: {
$setUnion: [
{
$filter: {
input: {
$map: {
input: { $ifNull: ["$dockerContainers", []] },
as: "c",
in: "$$c.base_image",
},
},
as: "img",
cond: {
$and: [{ $ne: ["$$img", null] }, { $ne: ["$$img", ""] }],
},
},
},
[],
],
},
};
return projectStage;
};
@@ -516,6 +562,7 @@ class MongoCheckRepository implements IChecksRepository {
.allowDiskUse(true)
.hint({ "metadata.monitorId": 1, createdAt: 1 });
console.log(checks);
return checks.map(this.toAggregateCheck);
};
+6 -5
View File
@@ -136,8 +136,6 @@ export interface CheckEntity {
expiry: Date;
}
// AggregateCheck reflects the minimal shape needed from aggregation results
// for list/history views, with string ids and optional docker payload.
export interface AggregateCheck {
// Time bucket identifier from aggregation (_id)
bucketDate: Date;
@@ -153,8 +151,12 @@ export interface AggregateCheck {
// Docker aggregates (counts per bucket)
totalContainers?: number;
runningContainers?: number;
runningPercent?: number;
healthyContainers?: number;
healthyPercent?: number;
runningContainersSnapshot?: IDockerContainerSummary[];
totalExposedPorts?: number;
uniqueImages?: number;
// PageSpeed aggregates
accessibility?: number | null;
bestPractices?: number | null;
@@ -166,8 +168,7 @@ export interface AggregateCheck {
lcp?: number | null;
tbt?: number | null;
// Infrastructure aggregates (optional snapshot/averages)
cpu?: Partial<ICpuInfo>;
// Infrastructure aggregates
memory?: Partial<IMemoryInfo>;
disk?: Partial<IDiskInfo>[];
host?: Partial<IHostInfo>;