Browse Source

sort rspamd symbols in debug log

friedPotat0 5 years ago
parent
commit
84617b0d6b
1 changed files with 11 additions and 1 deletions
  1. 11 1
      data/web/js/site/debug.js

+ 11 - 1
data/web/js/site/debug.js

@@ -468,7 +468,17 @@ jQuery(function($){
       else {
       else {
         item.rcpt = item.rcpt_smtp.join(", ");
         item.rcpt = item.rcpt_smtp.join(", ");
       }
       }
-      Object.keys(item.symbols).map(function(key) {
+      Object.keys(item.symbols).sort(function (a, b) {
+        if (item.symbols[a].score === 0) return 1
+        if (item.symbols[b].score === 0) return -1
+        if (item.symbols[b].score < 0 && item.symbols[a].score < 0) {
+          return item.symbols[a].score - item.symbols[b].score
+        }
+        if (item.symbols[b].score > 0 && item.symbols[a].score > 0) {
+          return item.symbols[b].score - item.symbols[a].score
+        }
+        return item.symbols[b].score - item.symbols[a].score
+      }).map(function(key) {
         var sym = item.symbols[key];
         var sym = item.symbols[key];
         if (sym.score < 0) {
         if (sym.score < 0) {
           sym.score_formatted = '(<span class="text-success"><b>' + sym.score + '</b></span>)'
           sym.score_formatted = '(<span class="text-success"><b>' + sym.score + '</b></span>)'