[Pkg-nagios-changes] [SCM] UNNAMED PROJECT branch, debian/master, updated. 810edbdd3feedbfe37f4a65bee50b57b2f60fa2a
Naparuba
naparuba at gmail.com
Tue Feb 28 22:20:59 UTC 2012
The following commit has been merged in the debian/master branch:
commit 08488ef9f7a920b3be6c2bc290dba34bfc33e0ee
Author: Naparuba <naparuba at gmail.com>
Date: Wed Feb 15 11:33:39 2012 +0100
Fix : duplicated elements in the /problems view.
diff --git a/shinken/misc/datamanager.py b/shinken/misc/datamanager.py
index 71814c8..31ef0cc 100644
--- a/shinken/misc/datamanager.py
+++ b/shinken/misc/datamanager.py
@@ -98,11 +98,12 @@ class DataManager(object):
# Returns all problems
- def get_all_problems(self):
+ def get_all_problems(self, to_sort=True):
res = []
res.extend([s for s in self.rg.services if s.state not in ['OK', 'PENDING'] and not s.is_impact and not s.problem_has_been_acknowledged and not s.host.problem_has_been_acknowledged])
res.extend([h for h in self.rg.hosts if h.state not in ['UP', 'PENDING'] and not h.is_impact and not h.problem_has_been_acknowledged])
- res.sort(hst_srv_sort)
+ if to_sort:
+ res.sort(hst_srv_sort)
return res
# Return all non managed impacts
diff --git a/shinken/misc/filter.py b/shinken/misc/filter.py
index 0a9595f..f1cff4f 100644
--- a/shinken/misc/filter.py
+++ b/shinken/misc/filter.py
@@ -32,11 +32,11 @@ def only_related_to(lst, user):
return lst
# Ok the user is a simple user, we should filter
- r = []
+ r = set()
for i in lst:
# Maybe the user is a direct contact
if user in i.contacts:
- r.append(i)
+ r.add(i)
continue
# TODO : add a notified_contact pass
@@ -44,7 +44,7 @@ def only_related_to(lst, user):
is_find = False
for s in i.source_problems:
if user in s.contacts:
- r.append(i)
+ r.add(i)
is_find = True
# Ok skeep this object now
if is_find:
@@ -52,7 +52,7 @@ def only_related_to(lst, user):
# Now impacts related maybe?
for imp in i.impacts:
if user in imp.contacts:
- r.append(i)
+ r.add(i)
- return r
+ return list(r)
diff --git a/shinken/webui/plugins/problems/problems.py b/shinken/webui/plugins/problems/problems.py
index 10d9da2..6e49f34 100644
--- a/shinken/webui/plugins/problems/problems.py
+++ b/shinken/webui/plugins/problems/problems.py
@@ -23,6 +23,7 @@
from shinken.webui.bottle import redirect
from shinken.misc.filter import only_related_to
+from shinken.misc.sorter import hst_srv_sort
### Will be populated by the UI with it's own value
app = None
@@ -49,11 +50,14 @@ def get_page():
search = app.request.GET.get('search', '')
- pbs = app.datamgr.get_all_problems()
+ pbs = app.datamgr.get_all_problems(to_sort=False)
# Filter with the user interests
pbs = only_related_to(pbs, user)
+ # Sort it now
+ pbs.sort(hst_srv_sort)
+
# Ok, if need, appli the search filter
if search:
print "SEARCHING FOR", search
--
UNNAMED PROJECT
More information about the Pkg-nagios-changes
mailing list