Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(projectHistoryLogs): remove audit logs according to constance configuration TASK-972 #5225

Merged
merged 14 commits into from
Nov 14, 2024

Conversation

Guitlle
Copy link
Contributor

@Guitlle Guitlle commented Nov 4, 2024

Checklist

  1. If you've added code that should be tested, add tests
  2. If you've changed APIs, update (or create!) the documentation
  3. Ensure the tests pass
  4. Run ./python-format.sh to make sure that your code lints and that you've followed our coding style
  5. Write a title and, if necessary, a description of your work suitable for publishing in our release notes
  6. Mention any related issues in this repository (as #ISSUE) and in other repositories (as kobotoolbox/other#ISSUE)
  7. Open an issue in the docs if there are UI/UX changes
  8. Create a testing plan for the reviewer and add it to the Testing section
  9. Add frontend or backend tag and any other appropriate tags to this pull request

Description

This PR adds the automatic expiration mechanism for project history logs. It is similar to the access log mechanism. The expiration time span is configured through constance.

Notes

All changes are on the audit_log kobo app.

Testing

  1. Change the title of an asset on Kobo
  2. Open a shell on django
$ ./run.py -cf exec kpi bash 
$ ./manage.py shell_plus
  1. Check that the change you just made is reflected in the last log metadata:
In [7]: ProjectHistoryLog.objects.last().metadata
Out[7]: 
{'name': {'new': 'Test test log', 'old': 'Test'},
 'source': 'Chrome (Linux)',
 'asset_uid': 'ae6hQt9s2phfjRnsNphLdA',
 'ip_address': '172.25.0.1',
 'log_subtype': 'project',
 'latest_version_uid': 'vi7x8mXHoWg7SVuW8sCnCS'}
  1. On the Django admin screen, go to constance Config and set the value of PROJECT_HISTORY_LOG_LIFESPAN to 0
  2. Execute the cleaning task:
In [8]: from kobo.apps.audit_log.tasks import spawn_logs_cleaning_tasks

In [9]: spawn_logs_cleaning_tasks()
  1. Check that there are no project history logs:
In [11]: len(ProjectHistoryLog.objects.all())
Out[11]: 0

Related issues

Fixes Notion TASK-972

Copy link

@Guitlle Guitlle self-assigned this Nov 5, 2024
@Guitlle Guitlle changed the title TASK-972 Remove audit logs according to constance configuration feat(projectHistoryLogs): remove audit logs according to constance configuration TASK-972 Nov 5, 2024
@Guitlle Guitlle marked this pull request as ready for review November 8, 2024 18:26
Copy link
Contributor

@rgraber rgraber left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some questions

@Guitlle Guitlle requested a review from rgraber November 13, 2024 00:00
@@ -44,6 +44,7 @@ export interface EnvironmentResponse {
*/
terms_of_service__sitewidemessage__exists: boolean;
open_rosa_server: string;
project_history_log_lifespan: number;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FE looks good :)

Copy link
Contributor

@rgraber rgraber left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@Guitlle Guitlle merged commit 878f80f into main Nov 14, 2024
7 checks passed
@Guitlle Guitlle deleted the task-972-remove-logs-constance-config branch November 14, 2024 19:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants