Skip to content

Commit

Permalink
create a ttl index for notifications
Browse files Browse the repository at this point in the history
does not delete notifications marked as DSA because we want them
to always remain visible for European users.
  • Loading branch information
nick-funk committed Feb 5, 2024
1 parent 6414d10 commit c595752
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
10 changes: 10 additions & 0 deletions INDEXES.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

```
Expand Down
2 changes: 2 additions & 0 deletions server/src/core/server/models/notifications/notification.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ export interface Notification extends TenantResource {
rejectionReason?: GQLREJECTION_REASON_CODE;
decisionDetails?: GQLNotificationDecisionDetails;
customReason?: string;

isDSA?: boolean;
}

type BaseConnectionInput = ConnectionInput<Notification>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,7 @@ export class InternalNotificationContext {
grounds: legal ? legal.grounds : undefined,
explanation: legal ? legal.explanation : undefined,
},
isDSA: true,
});

return notification;
Expand Down Expand Up @@ -438,6 +439,7 @@ export class InternalNotificationContext {
grounds: legal.grounds,
explanation: legal.explanation,
},
isDSA: true,
});

return notification;
Expand Down

0 comments on commit c595752

Please sign in to comment.