Browse Source

Data cleanup script: exclude previously-cleaned

The cleanup of old deleted comments and topics was repeatedly hitting
the same items even though they had already been cleaned up on previous
runs. This just explicitly excludes all the ones that have already had
their user_id info removed, so it will only hit ones that actually need
it.
merge-requests/19/head
Deimos 6 years ago
parent
commit
d1fccfd153
  1. 8
      tildes/scripts/clean_private_data.py

8
tildes/scripts/clean_private_data.py

@ -89,7 +89,9 @@ class DataCleaner():
updated = ( updated = (
self.db_session.query(Comment) self.db_session.query(Comment)
.filter( .filter(
Comment.deleted_time <= self.retention_cutoff) # type: ignore
Comment.deleted_time <= self.retention_cutoff, # type: ignore
Comment.user_id != 0,
)
.update({ .update({
'user_id': 0, 'user_id': 0,
'markdown': '', 'markdown': '',
@ -108,7 +110,9 @@ class DataCleaner():
updated = ( updated = (
self.db_session.query(Topic) self.db_session.query(Topic)
.filter( .filter(
Topic.deleted_time <= self.retention_cutoff) # type: ignore
Topic.deleted_time <= self.retention_cutoff, # type: ignore
Topic.user_id != 0,
)
.update({ .update({
'user_id': 0, 'user_id': 0,
'title': '', 'title': '',

Loading…
Cancel
Save