diff options
author | Étienne Loks <etienne.loks@iggdrasil.net> | 2020-01-30 17:48:22 +0100 |
---|---|---|
committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2020-07-01 18:02:28 +0200 |
commit | b95812657c142e26922ac8f9dbe72cbb56fc73b0 (patch) | |
tree | 9d8ed1b300d788d0893a5edbc7f530c7c486a397 /scripts/history_duplicate_clean.py | |
parent | a01045cb7b9523f6d0baa8ef9d537a26a189cdb4 (diff) | |
download | Ishtar-b95812657c142e26922ac8f9dbe72cbb56fc73b0.tar.bz2 Ishtar-b95812657c142e26922ac8f9dbe72cbb56fc73b0.zip |
Clean
Diffstat (limited to 'scripts/history_duplicate_clean.py')
-rw-r--r-- | scripts/history_duplicate_clean.py | 31 |
1 files changed, 0 insertions, 31 deletions
diff --git a/scripts/history_duplicate_clean.py b/scripts/history_duplicate_clean.py deleted file mode 100644 index 61d358720..000000000 --- a/scripts/history_duplicate_clean.py +++ /dev/null @@ -1,31 +0,0 @@ -""" -Clean duplicate in history. -This should be unecessary now. -""" - -import datetime -from archaeological_operations.models import Operation, AdministrativeAct -from archaeological_files.models import File -from archaeological_context_records.models import ContextRecord -from archaeological_finds.models import Find, BaseFind, Treatment - -nb_deleted = {} -to_delete = [] -for model in [Operation, File, ContextRecord, AdministrativeAct, Find, - BaseFind, Treatment]: - nb_deleted[model.__name__] = 0 - for item in model.objects.all()[0:]: - c_user, c_date = None, None - for h in item.history.order_by('-history_modifier_id', '-history_date', - '-history_id').all(): - if c_user and c_date and h.history_modifier_id == c_user and \ - c_date - h.history_date < datetime.timedelta(seconds=5): - to_delete.append(h) - c_user = h.history_modifier_id - c_date = h.history_date - nb_deleted[model.__name__] += len(to_delete) - -for item in to_delete: - item.delete() -for m in nb_deleted: - print "* %d deleted for %s" % (nb_deleted[m], m) |