Module: check_mk
Branch: master
Commit: 12d5ffae54e48ac66007355e55b394d8f5314f1f
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=12d5ffae54e48a…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Wed Mar 4 14:57:05 2015 +0100
#2042 Services are now sorted in a natural way, this affects services containing numbers
Previously services would be sorted alphabetically, e.g. <tt>foo1</tt>,
<tt>foo10</tt>, <tt>foo11</tt>, ... <tt>foo2</tt>,
<tt>foo3</tt>, etc.
Now numbers within the descriptions are being detected by a smart algorithm
and the sorting is then <tt>foo1</tt>, <tt>foo2</tt>, ... ,
<tt>foo9</tt>,
<tt>foo10</tt>, <tt>foo11</tt>, just as you would expect.
---
.werks/2042 | 13 +++++++++++++
ChangeLog | 1 +
web/plugins/views/sorters.py | 7 ++-----
3 files changed, 16 insertions(+), 5 deletions(-)
diff --git a/.werks/2042 b/.werks/2042
new file mode 100644
index 0000000..465cdba
--- /dev/null
+++ b/.werks/2042
@@ -0,0 +1,13 @@
+Title: Services are now sorted in a natural way, this affects services containing
numbers
+Level: 2
+Component: multisite
+Compatible: compat
+Version: 1.2.7i1
+Date: 1425477221
+Class: feature
+
+Previously services would be sorted alphabetically, e.g. <tt>foo1</tt>,
+<tt>foo10</tt>, <tt>foo11</tt>, ... <tt>foo2</tt>,
<tt>foo3</tt>, etc.
+Now numbers within the descriptions are being detected by a smart algorithm
+and the sorting is then <tt>foo1</tt>, <tt>foo2</tt>, ... ,
<tt>foo9</tt>,
+<tt>foo10</tt>, <tt>foo11</tt>, just as you would expect.
diff --git a/ChangeLog b/ChangeLog
index dcf70e1..9903b9a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -238,6 +238,7 @@
* 1979 Relative timestamps display warnings when they should be in future but are in
past
* 1937 cpu.loads: performance graph now displays number of CPUs
* 2040 Allow commands for setting downtimes and acknowledging on BI aggregates...
+ * 2042 Services are now sorted in a natural way, this affects services containing
numbers...
* 1781 FIX: Fix broken grouping by host/service group in availability
* 1783 FIX: Finish the view "History of Scheduled Downtimes"...
* 1206 FIX: Hostname not longer shown as column in host views
diff --git a/web/plugins/views/sorters.py b/web/plugins/views/sorters.py
index 0317d5c..e724b31 100644
--- a/web/plugins/views/sorters.py
+++ b/web/plugins/views/sorters.py
@@ -142,11 +142,8 @@ def cmp_service_name_equiv(r):
return 0
def cmp_service_name(column, r1, r2):
- o = cmp(cmp_service_name_equiv(r1[column]), cmp_service_name_equiv(r2[column]))
- if o == 0:
- return cmp_simple_string(column, r1, r2)
- else:
- return o
+ return cmp(cmp_service_name_equiv(r1[column]), cmp_service_name_equiv(r2[column])) or
\
+ cmp_num_split(column, r1, r2)
# name title
column sortfunction
declare_simple_sorter("svcdescr", _("Service
description"), "service_description", cmp_service_name)