feat: Script deletion of old notifications (startinblox/applications/sib-app#228)

This commit is contained in:
Christophe Henry
2019-10-16 18:12:01 +02:00
parent f278f759fb
commit 0529397a88
3 changed files with 102 additions and 2 deletions

View File

@ -44,4 +44,51 @@ When an object is saved, a notification is created for all the subscriptions rel
## Send email when new notification
When a notification is created, an email is sent to the user.
When a notification is created, an email is sent to the user.
# Django commands
This package also bring a few Django managment command. You can use them
at the root of your SIB project.
## `mock_notification`
This lets you create mocked notifications. Useful for develpment.
Usage:
```
python3 manage.py mock_notification [--size <number_of_notifications>]
```
Will create the number of dummy notifications specified by `--size`.
By default, 0.
## `suppress_old_notifications`
Will suppress old notification. This is a maintenance command to prevent
the server to blow under the weight of your notifications.
Usage:
```
python3 manage.py mock_notification [--older <time_period>]
```
This will erase notification older than the time period specified by
`--older`. By default, 72h ago. `time_period` is expressed in minutes.
`d`, `h` and `m` suffix are also valid to express periods in days,
hours and minutes.
Examples:
```shell
# Default. Will delete notifications older than 72h
python3 manage.py mock_notification
# Default. Will delete notifications older than 10 minutes ago
python3 manage.py mock_notification --older 10
# Default. Will delete notifications older than 10 days ago
python3 manage.py mock_notification --older 10d
# Default. Will delete notifications older than 10 hours ago
python3 manage.py mock_notification --older 10h
```