Merge pull request #3975 from nikhilsaxena04/feat/status-page-incident-history

feat: add clickthrough incident history to public status page (#3972)
This commit is contained in:
Alexander Holliday authored and GitHub committed 2026-09-22 10:15:57 -07:00
commit a5e66318b5
39 files changed
+427 -44

No files matched your search

@@ -82,6 +82,7 @@ IncidentSchema.index({ teamId: 1, startTime: -1 });
IncidentSchema.index({ status: 1, startTime: -1 });
IncidentSchema.index({ resolutionType: 1, status: 1 });
IncidentSchema.index({ resolvedBy: 1, status: 1 });
IncidentSchema.index({ monitorId: 1, startTime: -1 });
IncidentSchema.index({ createdAt: -1 });
const IncidentModel = model<IncidentDocument>("Incident", IncidentSchema);
@@ -17,6 +17,7 @@ export interface IIncidentsRepository {
monitorId?: string,
resolutionType?: string
): Promise<Incident[]>;
findByMonitorIdAndDate(monitorId: string, teamId: string, dateStart: Date, dateEnd: Date): Promise<Incident[]>;
findSummaryByTeamId(teamId: string, limit?: number): Promise<IncidentSummary>;
countByTeamId(teamId: string, startDate: Date | undefined, status?: boolean, monitorId?: string, resolutionType?: string): Promise<number>;
@@ -120,6 +120,17 @@ class MongoIncidentsRepository implements IIncidentsRepository {
return this.mapDocuments(incidents);
};
findByMonitorIdAndDate = async (monitorId: string, teamId: string, dateStart: Date, dateEnd: Date): Promise<Incident[]> => {
const matchStage = {
monitorId: new mongoose.Types.ObjectId(monitorId),
teamId: new mongoose.Types.ObjectId(teamId),
startTime: { $lt: dateEnd },
$or: [{ endTime: null }, { endTime: { $gte: dateStart } }],
};
const incidents = await IncidentModel.find(matchStage).sort({ startTime: -1 });
return this.mapDocuments(incidents);
};
updateById = async (incidentId: string, teamId: string, patch: Partial<Incident>) => {
const updatedIncident = await IncidentModel.findOneAndUpdate(
{ _id: new mongoose.Types.ObjectId(incidentId), teamId: new mongoose.Types.ObjectId(teamId) },
@@ -20,6 +20,11 @@ export interface Incident {
updatedAt: string;
}
export type PublicIncident = Pick<
Incident,
"id" | "monitorId" | "status" | "startTime" | "endTime" | "resolutionType" | "message" | "statusCode" | "createdAt"
>;
export interface IncidentSummaryTopMonitor {
monitorId: string;
monitorName: string | null;