server format
This commit is contained in:
1 parent
117a2e00c4
commit
e79bf28bdc
4 files changed
+16
-24
No files matched your search
@@ -19,10 +19,10 @@ const backupAndDropExistingCollection = async () => {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
await db.collection(CHECKS_COLLECTION).aggregate([
|
await db
|
||||||
{ $match: {} },
|
.collection(CHECKS_COLLECTION)
|
||||||
{ $out: BACKUP_COLLECTION },
|
.aggregate([{ $match: {} }, { $out: BACKUP_COLLECTION }])
|
||||||
]).toArray();
|
.toArray();
|
||||||
await db.collection(CHECKS_COLLECTION).drop();
|
await db.collection(CHECKS_COLLECTION).drop();
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
@@ -40,12 +40,14 @@ const createTimeSeriesCollection = async () => {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
await db.collection(CHECKS_COLLECTION).createIndexes([
|
await db
|
||||||
{ key: { updatedAt: 1 } },
|
.collection(CHECKS_COLLECTION)
|
||||||
{ key: { "metadata.monitorId": 1, updatedAt: 1 } },
|
.createIndexes([
|
||||||
{ key: { "metadata.monitorId": 1, updatedAt: -1 } },
|
{ key: { updatedAt: 1 } },
|
||||||
{ key: { "metadata.teamId": 1, updatedAt: -1 } },
|
{ key: { "metadata.monitorId": 1, updatedAt: 1 } },
|
||||||
]);
|
{ key: { "metadata.monitorId": 1, updatedAt: -1 } },
|
||||||
|
{ key: { "metadata.teamId": 1, updatedAt: -1 } },
|
||||||
|
]);
|
||||||
};
|
};
|
||||||
|
|
||||||
const migrateBackupData = async () => {
|
const migrateBackupData = async () => {
|
||||||
|
|||||||
@@ -32,11 +32,7 @@ const runMigrations = async (logger?: { info: Function; error: Function }) => {
|
|||||||
logger?.info({ message: `Completed ${migration.name}`, service: "Migrations" });
|
logger?.info({ message: `Completed ${migration.name}`, service: "Migrations" });
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
const err = error as Error;
|
const err = error as Error;
|
||||||
await MigrationModel.findOneAndUpdate(
|
await MigrationModel.findOneAndUpdate({ name: migration.name }, { status: "failed", error: err?.message }, { upsert: true });
|
||||||
{ name: migration.name },
|
|
||||||
{ status: "failed", error: err?.message },
|
|
||||||
{ upsert: true }
|
|
||||||
);
|
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,5 @@
|
|||||||
import { Schema, model, Types } from "mongoose";
|
import { Schema, model, Types } from "mongoose";
|
||||||
import {
|
import { MonitorTypes, type MonitorType } from "@/types/monitor.js";
|
||||||
MonitorTypes,
|
|
||||||
type MonitorType,
|
|
||||||
} from "@/types/monitor.js";
|
|
||||||
import type {
|
import type {
|
||||||
Check,
|
Check,
|
||||||
CheckAudits,
|
CheckAudits,
|
||||||
@@ -25,10 +22,7 @@ type CheckMetadataDocument = Omit<CheckMetadata, "monitorId" | "teamId"> & {
|
|||||||
type: MonitorType;
|
type: MonitorType;
|
||||||
};
|
};
|
||||||
|
|
||||||
type CheckDocumentBase = Omit<
|
type CheckDocumentBase = Omit<Check, "id" | "metadata" | "expiry" | "ackAt" | "createdAt" | "updatedAt"> & {
|
||||||
Check,
|
|
||||||
"id" | "metadata" | "expiry" | "ackAt" | "createdAt" | "updatedAt"
|
|
||||||
> & {
|
|
||||||
metadata: CheckMetadataDocument;
|
metadata: CheckMetadataDocument;
|
||||||
expiry: Date;
|
expiry: Date;
|
||||||
ackAt?: Date | null;
|
ackAt?: Date | null;
|
||||||
|
|||||||
@@ -374,7 +374,7 @@ class StatusService {
|
|||||||
return {
|
return {
|
||||||
id: audit.id,
|
id: audit.id,
|
||||||
title: audit.title,
|
title: audit.title,
|
||||||
score: typeof audit.score === "number" ? audit.score : audit.score ?? null,
|
score: typeof audit.score === "number" ? audit.score : (audit.score ?? null),
|
||||||
displayValue: audit.displayValue,
|
displayValue: audit.displayValue,
|
||||||
numericValue: typeof audit.numericValue === "number" ? audit.numericValue : undefined,
|
numericValue: typeof audit.numericValue === "number" ? audit.numericValue : undefined,
|
||||||
numericUnit: audit.numericUnit,
|
numericUnit: audit.numericUnit,
|
||||||
|
|||||||
Reference in new issue
Block a user