Skip to content

Commit

Permalink
Fix dataminimisation integrityerror
Browse files Browse the repository at this point in the history
  • Loading branch information
DeD1rk committed Jan 11, 2024
1 parent 3431d2a commit 97d4b52
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
3 changes: 1 addition & 2 deletions website/thaliawebsite/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,7 @@ def data_minimisation():
logger.info(f"Removed reference faces: {p}")

processed = minimise_logentries_data()
for p in processed:
logger.info(f"Removed user from logentries for {p}")
logger.info(f"Removed {processed} log entries")


@shared_task
Expand Down
10 changes: 5 additions & 5 deletions website/utils/snippets.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,9 +240,9 @@ def minimise_logentries_data(dry_run=False):
# Sometimes years are 366 days of course, but better delete 1 or 2 days early than late
deletion_period = timezone.now().date() - timezone.timedelta(days=365 * 7)

queryset = LogEntry.objects.filter(action_time__lte=deletion_period).exclude(
user__isnull=True
)
qs = LogEntry.objects.filter(action_time__lte=deletion_period)
if not dry_run:
queryset.update(user=None)
return queryset
count, _ = qs.delete()
else:
count = qs.count()
return count

0 comments on commit 97d4b52

Please sign in to comment.