diff --git a/INDEXES.md b/INDEXES.md index 2c8597d6c1..c6a89db475 100644 --- a/INDEXES.md +++ b/INDEXES.md @@ -6,6 +6,16 @@ The goal of this document is to date-mark the indexes you add to support the cha If you are releasing, you can use this readme to check all the indexes prior to the release you are deploying and have a good idea of what indexes you might need to deploy to Mongo along with your release of a new Coral Docker image to kubernetes. +## 2024-02-02 + +``` +db.notifications.createIndex({ createdAt: 1 }, { partialFilterExpression: { isDSA: { $eq: null } }, expireAfterSeconds: 30 * 24 * 60 * 60 }); +``` + +- This creates a TTL on non-DSA marked notifications that will delete them after 30 days + - The `partialFilterExpression` finds any notifications that aren't marked as `isDSA` so we don't delete important DSA notifications + - You can modify the expiry time by changing `expireAfterSeconds` + ## 2023-11-24 ``` diff --git a/server/src/core/server/models/notifications/notification.ts b/server/src/core/server/models/notifications/notification.ts index 5b2fa6fce5..031b14e90d 100644 --- a/server/src/core/server/models/notifications/notification.ts +++ b/server/src/core/server/models/notifications/notification.ts @@ -30,6 +30,8 @@ export interface Notification extends TenantResource { rejectionReason?: GQLREJECTION_REASON_CODE; decisionDetails?: GQLNotificationDecisionDetails; customReason?: string; + + isDSA?: boolean; } type BaseConnectionInput = ConnectionInput; diff --git a/server/src/core/server/services/notifications/internal/context.ts b/server/src/core/server/services/notifications/internal/context.ts index f9492c9162..c888dc7df6 100644 --- a/server/src/core/server/services/notifications/internal/context.ts +++ b/server/src/core/server/services/notifications/internal/context.ts @@ -402,6 +402,7 @@ export class InternalNotificationContext { grounds: legal ? legal.grounds : undefined, explanation: legal ? legal.explanation : undefined, }, + isDSA: true, }); return notification; @@ -438,6 +439,7 @@ export class InternalNotificationContext { grounds: legal.grounds, explanation: legal.explanation, }, + isDSA: true, }); return notification;