diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2018-02-15 15:28:47 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2018-02-15 15:28:47 +0000 |
commit | 5a9b7ee710a43901b7cc6605506be035bfe335b1 (patch) | |
tree | f3a5cdb82ca3f6ef68e9e77fa35f264da022567b /lualib/rspamadm | |
parent | 4b7e987b91a8782d5558f24cbd6bda7a70a53da1 (diff) | |
download | rspamd-5a9b7ee710a43901b7cc6605506be035bfe335b1.tar.gz rspamd-5a9b7ee710a43901b7cc6605506be035bfe335b1.zip |
[Project] Preliminary version of the new stat_convert
Diffstat (limited to 'lualib/rspamadm')
-rw-r--r-- | lualib/rspamadm/stat_convert.lua | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/lualib/rspamadm/stat_convert.lua b/lualib/rspamadm/stat_convert.lua index 3845702da..7c902dd99 100644 --- a/lualib/rspamadm/stat_convert.lua +++ b/lualib/rspamadm/stat_convert.lua @@ -1,7 +1,35 @@ local lua_redis = require "rspamd_redis" local stat_tools = require "stat_tools" +local ucl = require "ucl" +local logger = require "rspamd_logger" return function (_, res) - local redis_params = + local redis_params = {} + if not lua_redis.try_load_redis_servers(res.redis, nil, redis_params) then + logger.errx('cannot load redis server definition') + + return false + end + + local sqlite_params = stat_tools.load_sqlite_config(res) + + if #sqlite_params == 0 then + logger.errx('cannot load sqlite classifiers') + return false + end + + for _,cls in ipairs(sqlite_params) do + if not stat_tools.convert_sqlite_to_redis(redis_params, cls.db_spam, + cls.db_ham, cls.symbol_spam, cls.symbol_ham, cls.learn_cache, res.expire, + res.reset_previous) then + logger.errx('conversion failed') + + return false + end + logger.infox('Converted classifier to the from sqlite to redis') + logger.infox('Suggested configuration:') + logger.infox(ucl.to_format(stat_tools.redis_classifier_from_sqlite(cls), + 'config')) + end end |