summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTim Laszlo <tim.laszlo@gmail.com>2013-01-30 09:29:04 -0600
committerTim Laszlo <tim.laszlo@gmail.com>2013-01-30 09:29:04 -0600
commitc2ec71065a75adb05178547f4fd3431178a06500 (patch)
tree2ac4461396ea5b3cfd78f42c28d675fcc816ad32
parent86f5e4cb5d4b9988fb67f6611f83a058267b203c (diff)
downloadbcfg2-c2ec71065a75adb05178547f4fd3431178a06500.tar.gz
bcfg2-c2ec71065a75adb05178547f4fd3431178a06500.tar.bz2
bcfg2-c2ec71065a75adb05178547f4fd3431178a06500.zip
Batch deletes for sqlite
-rw-r--r--src/lib/Bcfg2/Reporting/models.py8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/lib/Bcfg2/Reporting/models.py b/src/lib/Bcfg2/Reporting/models.py
index c7850f4af..ab2dc8418 100644
--- a/src/lib/Bcfg2/Reporting/models.py
+++ b/src/lib/Bcfg2/Reporting/models.py
@@ -392,7 +392,13 @@ class BaseEntry(models.Model):
@classmethod
def prune_orphans(cls):
'''Remove unused entries'''
- cls.objects.filter(interaction__isnull=True).delete()
+ # yeat another sqlite hack
+ cls_orphans = [x['id'] \
+ for x in cls.objects.filter(interaction__isnull=True).values("id")]
+ i = 0
+ while i < len(cls_orphans):
+ cls.objects.filter(id__in=cls_orphans[i:i+100]).delete()
+ i += 100
class SuccessEntry(BaseEntry):