From 804e18867ff4fb06c29f37674019c253675396aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Schl=C3=B6gl?= Date: Fri, 4 Oct 2024 11:32:28 +0200 Subject: [PATCH] docs(history): add documentation on some management commands resolves #873 --- docs/source/features.rst | 37 ++++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/docs/source/features.rst b/docs/source/features.rst index 337d9444b..74bf364b4 100644 --- a/docs/source/features.rst +++ b/docs/source/features.rst @@ -48,6 +48,41 @@ can be accessed under `/apis/swagger/schema/swagger-ui/#/apis/apis_api_history_e .. _django-simple-history: https://django-simple-history.readthedocs.io/en/latest/ +Management Commands +^^^^^^^^^^^^^^^^^^^ + +The APIS history plugin, based on `django-simple-history`, provides several management commands to help curate history objects. Here are some of the most useful commands: + +1. Populate History Tables +-------------------------- + +.. code-block:: bash + + python manage.py populate_history --auto + +This command populates history tables with the current state of the models. It's particularly useful when you've added `VersionMixin` to an existing model. The `--auto` flag applies the command to all tracked models, or you can specify a list of models instead. + +2. Clean Duplicate History Entries +---------------------------------- + +.. code-block:: bash + + python manage.py clean_duplicate_history --auto + +This command removes duplicate history entries. `django-simple-history` creates a history object every time `save()` is called on an object, regardless of whether any changes were made. This command deletes history objects that are identical to the previous entry. + +3. Remove Old History Entries +----------------------------- + +.. code-block:: bash + + python manage.py clean_old_history --days 60 --auto + +This command deletes history entries older than the specified number of days (60 in this example). + +For more information on these and other management commands, refer to the `django-simple-history documentation `_. + + Collections plugin ------------------ @@ -111,4 +146,4 @@ a collection to point to the collections parent. This is useful if you want to implement a workflow (i.e. three collections: `done` as the root one, `in process` with `done` as parent and `todo` with `in process` as parent - the user can then on the click of a button change an the collection an instance is -connected to) \ No newline at end of file +connected to)