update pagespeed

This commit is contained in:
Alex Holliday committed 2026-01-12 23:57:39 +00:00
1 parent 7a6b0d5da4
commit 25d1039376
204 files changed
+977 -343

No files matched your search

+18 -5
View File
@@ -16,6 +16,7 @@ import type {
CheckNetworkInterfaceInfo,
CheckTimings,
CheckTimingPhases,
ILighthouseAudit,
} from "@/types/check.js";
type CheckMetadataDocument = Omit<CheckMetadata, "monitorId" | "teamId"> & {
@@ -149,13 +150,25 @@ const networkInterfaceSchema = new Schema<CheckNetworkInterfaceInfo>(
{ _id: false }
);
const lighthouseAuditSchema = new Schema<ILighthouseAudit>(
{
id: { type: String },
title: { type: String },
score: { type: Number },
displayValue: { type: String },
numericValue: { type: Number },
numericUnit: { type: String },
},
{ _id: false }
);
const auditsSchema = new Schema<CheckAudits>(
{
cls: { type: Number, default: 0 },
si: { type: Number, default: 0 },
fcp: { type: Number, default: 0 },
lcp: { type: Number, default: 0 },
tbt: { type: Number, default: 0 },
cls: { type: lighthouseAuditSchema, default: undefined },
si: { type: lighthouseAuditSchema, default: undefined },
fcp: { type: lighthouseAuditSchema, default: undefined },
lcp: { type: lighthouseAuditSchema, default: undefined },
tbt: { type: lighthouseAuditSchema, default: undefined },
},
{ _id: false }
);
+1 -1
View File
@@ -22,7 +22,7 @@ class CheckModule {
createChecks = async (checks) => {
try {
await CheckModel.insertMany(checks, { ordered: false });
await CheckModel.insertMany(checks, { ordered: false, runValidators: true });
} catch (error) {
error.service = SERVICE_NAME;
error.method = "createCheck";
-1
View File
@@ -242,7 +242,6 @@ class MonitorModule {
const dateString = formatLookup[dateRange];
console.log("WTTTTFFF");
const results = await CheckModel.aggregate(buildUptimeDetailsPipeline(monitorId, dates, dateString));
const monitorData = results[0];
@@ -220,7 +220,6 @@ class MonitorService {
};
getMonitorsByTeamId = async ({ teamId, limit, type, page, rowsPerPage, filter, field, order }) => {
console.log("que");
const monitors = await this.db.monitorModule.getMonitorsByTeamId({
limit,
type,
@@ -367,18 +367,30 @@ class StatusService {
}
const categories = payload?.lighthouseResult?.categories ?? {};
const audits = payload?.lighthouseResult?.audits ?? {};
const {
"cumulative-layout-shift": cls = 0,
"speed-index": si = 0,
"first-contentful-paint": fcp = 0,
"largest-contentful-paint": lcp = 0,
"total-blocking-time": tbt = 0,
} = audits;
const mapAudit = (audit) => {
if (!audit || typeof audit !== "object") {
return undefined;
}
return {
id: audit.id,
title: audit.title,
score: typeof audit.score === "number" ? audit.score : audit.score ?? null,
displayValue: audit.displayValue,
numericValue: typeof audit.numericValue === "number" ? audit.numericValue : undefined,
numericUnit: audit.numericUnit,
};
};
check.accessibility = (categories?.accessibility?.score || 0) * 100;
check.bestPractices = (categories?.["best-practices"]?.score || 0) * 100;
check.seo = (categories?.seo?.score || 0) * 100;
check.performance = (categories?.performance?.score || 0) * 100;
check.audits = { cls, si, fcp, lcp, tbt };
check.audits = {
cls: mapAudit(audits?.["cumulative-layout-shift"]),
si: mapAudit(audits?.["speed-index"]),
fcp: mapAudit(audits?.["first-contentful-paint"]),
lcp: mapAudit(audits?.["largest-contentful-paint"]),
tbt: mapAudit(audits?.["total-blocking-time"]),
};
}
if (type === "hardware") {
+14 -5
View File
@@ -86,11 +86,20 @@ export interface CheckNetworkInterfaceInfo {
}
export interface CheckAudits {
cls: number;
si: number;
fcp: number;
lcp: number;
tbt: number;
cls: ILighthouseAudit;
si: ILighthouseAudit;
fcp: ILighthouseAudit;
lcp: ILighthouseAudit;
tbt: ILighthouseAudit;
}
export interface ILighthouseAudit {
id?: string;
title?: string;
score?: number | null;
displayValue?: string;
numericValue?: number;
numericUnit?: string;
}
export interface Check {