This commit is contained in:
Alex Holliday committed 2025-12-18 19:04:44 +00:00
1 parent 1ee8a873f6
commit aa346abf5b
4 files changed
+32 -8

No files matched your search

+3
View File
@@ -163,5 +163,8 @@ MonitorSchema.index({ type: 1 });
MonitorSchema.index({ lastCheckedAt: 1 });
MonitorSchema.index({ createdBy: 1 });
MonitorSchema.index({ updatedBy: 1 });
// Common filter keys used across services and routes
MonitorSchema.index({ teamId: 1 });
MonitorSchema.index({ orgId: 1 });
export const Monitor = mongoose.model<IMonitor>("Monitor", MonitorSchema);
@@ -26,7 +26,7 @@ const MonitorStatsSchema = new Schema<IMonitorStats>(
type: mongoose.Schema.Types.ObjectId,
ref: "Monitor",
immutable: true,
index: true,
unique: true,
},
avgResponseTime: {
type: Number,
+12 -3
View File
@@ -92,8 +92,18 @@ const InfraNetEntrySchema = new Schema<IInfraNetEntry>(
const StatsDailySchema = new Schema<IStatsDaily>(
{
monitorId: { type: Schema.Types.ObjectId, ref: "Monitor", index: true, required: true },
teamId: { type: Schema.Types.ObjectId, ref: "Team", index: true, required: true },
monitorId: {
type: Schema.Types.ObjectId,
ref: "Monitor",
index: true,
required: true,
},
teamId: {
type: Schema.Types.ObjectId,
ref: "Team",
index: true,
required: true,
},
type: { type: String, required: true },
windowStart: { type: Date, required: true, index: true },
windowEnd: { type: Date, required: true },
@@ -126,7 +136,6 @@ const StatsDailySchema = new Schema<IStatsDaily>(
{ timestamps: true, collection: "stats_daily" }
);
// One document per (monitorId, windowStart)
StatsDailySchema.index({ monitorId: 1, windowStart: 1 }, { unique: true });
export const StatsDaily = mongoose.model<IStatsDaily>(
+16 -4
View File
@@ -87,7 +87,10 @@ export interface IInfraNetEntry {
fifo_out?: number;
}
export interface IStatsHourly extends mongoose.Document, IStatsBase, IPageSpeedMetrics {
export interface IStatsHourly
extends mongoose.Document,
IStatsBase,
IPageSpeedMetrics {
cpu?: IInfraCpu;
memory?: IInfraMemory;
disk?: IInfraDiskEntry[];
@@ -166,8 +169,18 @@ const InfraNetEntrySchema = new Schema<IInfraNetEntry>(
const StatsHourlySchema = new Schema<IStatsHourly>(
{
monitorId: { type: Schema.Types.ObjectId, ref: "Monitor", index: true, required: true },
teamId: { type: Schema.Types.ObjectId, ref: "Team", index: true, required: true },
monitorId: {
type: Schema.Types.ObjectId,
ref: "Monitor",
index: true,
required: true,
},
teamId: {
type: Schema.Types.ObjectId,
ref: "Team",
index: true,
required: true,
},
type: { type: String, required: true },
windowStart: { type: Date, required: true, index: true },
windowEnd: { type: Date, required: true },
@@ -200,7 +213,6 @@ const StatsHourlySchema = new Schema<IStatsHourly>(
{ timestamps: true, collection: "stats_hourly" }
);
// One document per (monitorId, windowStart)
StatsHourlySchema.index({ monitorId: 1, windowStart: 1 }, { unique: true });
export const StatsHourly = mongoose.model<IStatsHourly>(