From 3f3d2138aca930c59a2139f6ff2a5405c2449fe5 Mon Sep 17 00:00:00 2001 From: Tim Laszlo Date: Thu, 14 Jun 2012 10:20:12 -0500 Subject: DBStats: Start loading good entries into the db --- src/lib/Bcfg2/Server/Reports/reports/models.py | 2 ++ src/lib/Bcfg2/Server/Reports/reports/views.py | 8 ++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) (limited to 'src/lib/Bcfg2/Server/Reports/reports') diff --git a/src/lib/Bcfg2/Server/Reports/reports/models.py b/src/lib/Bcfg2/Server/Reports/reports/models.py index 750add34d..3bce17a30 100644 --- a/src/lib/Bcfg2/Server/Reports/reports/models.py +++ b/src/lib/Bcfg2/Server/Reports/reports/models.py @@ -23,11 +23,13 @@ KIND_CHOICES = ( ('Path', 'symlink'), ('Service', 'Service'), ) +TYPE_GOOD = 0 TYPE_BAD = 1 TYPE_MODIFIED = 2 TYPE_EXTRA = 3 TYPE_CHOICES = ( + (TYPE_GOOD, 'Good'), (TYPE_BAD, 'Bad'), (TYPE_MODIFIED, 'Modified'), (TYPE_EXTRA, 'Extra'), diff --git a/src/lib/Bcfg2/Server/Reports/reports/views.py b/src/lib/Bcfg2/Server/Reports/reports/views.py index 2e2c361fe..439d01c7c 100644 --- a/src/lib/Bcfg2/Server/Reports/reports/views.py +++ b/src/lib/Bcfg2/Server/Reports/reports/views.py @@ -231,9 +231,11 @@ def common_problems(request, timestamp=None, threshold=None): threshold = 10 c_intr = Interaction.objects.get_interaction_per_client_ids(timestamp) - data_list = { 1: {}, 2: {}, 3: {}} + data_list = {} + [data_list.__setitem__(t_id, {}) \ + for t_id, t_label in TYPE_CHOICES if t_id != TYPE_GOOD] ldata = list(Entries_interactions.objects.filter( - interaction__in=c_intr).values()) + interaction__in=c_intr).exclude(type=TYPE_GOOD).values()) entry_ids = set([x['entry_id'] for x in ldata]) reason_ids = set([x['reason_id'] for x in ldata]) @@ -250,6 +252,8 @@ def common_problems(request, timestamp=None, threshold=None): lists = [] for type, type_name in TYPE_CHOICES: + if type == TYPE_GOOD: + continue lists.append([type_name.lower(), [(entries[e[0][0]], reasons[e[0][1]], e[1]) for e in sorted(data_list[type].items(), key=lambda x: len(x[1]), reverse=True) if len(e[1]) > threshold]]) -- cgit v1.2.3-1-g7c22