yunojuno / django-request-token

Django app that uses JWT to manage one-time and expiring tokens to protected URLs. Not related to DRF.
MIT License
47 stars 23 forks source link

Add management command to truncate logs #54

Closed hugorodgerbrown closed 3 years ago

hugorodgerbrown commented 3 years ago

Solves issue #53

This PR adds a new management command called truncate_request_token_log which can be run on a schedule to ensure that logs don't grow excessively. It supports a log cap defined by date (number of days) or raw count ( number of records), or both:

# truncate to a max count of 1000 records - NB this should be less than any
# hard limit you have as the log will continue to grow over the limit until the
# next time it is run. 
$ python manage.py truncate_request_token_log --max-count=1000

# truncate to last 90 days
$ python manage.py truncate_request_token_log --max-days=90