aboutsummaryrefslogtreecommitdiffstats
path: root/interface
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2017-03-20 14:11:58 +0000
committerVsevolod Stakhov <vsevolod@highsecure.ru>2017-03-20 14:11:58 +0000
commit3f72bccd49234103b6ed4adee6f26f9c1d12d8d0 (patch)
tree343c381545425f0593d5b7baada5c219aaf0f7c1 /interface
parent92d4711385ac3647096bcd7a08029d1d7cfda03f (diff)
downloadrspamd-3f72bccd49234103b6ed4adee6f26f9c1d12d8d0.tar.gz
rspamd-3f72bccd49234103b6ed4adee6f26f9c1d12d8d0.zip
[WebUI] Try to normalize frequencies
Diffstat (limited to 'interface')
-rw-r--r--interface/js/app/symbols.js28
1 files changed, 28 insertions, 0 deletions
diff --git a/interface/js/app/symbols.js b/interface/js/app/symbols.js
index 6e9d01634..0d68c137f 100644
--- a/interface/js/app/symbols.js
+++ b/interface/js/app/symbols.js
@@ -97,6 +97,8 @@ function($) {
success: function (data) {
var distinct_groups = [];
var lookup = {};
+ var freqs = [];
+
$.each(data, function (i, group) {
$.each(group.rules, function (i, item) {
var max = 20;
@@ -127,6 +129,7 @@ function($) {
if (!item.frequency) {
item.frequency = 0;
}
+ freqs.push(item.frequency);
item.frequency = Number(item.frequency).toFixed(2)
if (!(item.group in lookup)) {
lookup[item.group] = 1;
@@ -137,6 +140,31 @@ function($) {
items.push(item)
});
});
+ // For better mean calculations
+ var avg_freq = freqs.sort(function(a, b) {
+ return Number(a) < Number(b);
+ }).reduce(function(f1, acc) {
+ return f1 + acc;
+ }) / (freqs.length != 0 ? freqs.length : 1.0);
+ var mult = 1.0;
+ var exp = 0.0;
+
+ if (avg_freq > 0.0) {
+ while (mult * avg_freq < 1.0) {
+ mult *= 10;
+ exp ++;
+ }
+ }
+ $.each(items, function (i, item) {
+ item.frequency = Number(item.frequency) * mult;
+
+ if (exp > 0) {
+ item.frequency = item.frequency.toFixed(2) + 'e-' + exp;
+ }
+ else {
+ item.frequency = item.frequency.toFixed(2);
+ }
+ });
FooTable.groupFilter = FooTable.Filtering.extend({
construct : function(instance) {
this._super(instance);