return match(ptrim, s)
end
+-- Robert Jay Gould http://lua-users.org/wiki/SimpleRound
+exports.round = function(num, numDecimalPlaces)
+ local mult = 10^(numDecimalPlaces or 0)
+ return math.floor(num * mult + 0.5) / mult
+end
+
return exports
local rspamd_tcp = require "rspamd_tcp"
local rspamd_util = require "rspamd_util"
local rspamd_logger = require "rspamd_logger"
+local lutil = require "lua_util"
local ucl = require "ucl"
local E = {}
local N = 'metadata_exporter'
r.user = task:get_user() or 'unknown'
r.qid = task:get_queue_id() or 'unknown'
r.action = task:get_metric_action('default')
- r.score = string.format('%.2f', task:get_metric_score('default')[1])
+ r.score = lutil.round(task:get_metric_score('default')[1], 2)
local rcpt = task:get_recipients('smtp')
if rcpt then
local l = {}