# HG changeset patch # User Kim Alvefur # Date 1579458466 -3600 # Node ID 3941768916f1af53ec39e4852301760fb1292e58 # Parent 117f0fb8cb15137f76a45f01000c9f7ea59df32b mod_stats39: Format numbers with a bit more precision diff -r 117f0fb8cb15 -r 3941768916f1 mod_stats39/mod_stats39.lua --- a/mod_stats39/mod_stats39.lua Sun Jan 19 19:27:17 2020 +0100 +++ b/mod_stats39/mod_stats39.lua Sun Jan 19 19:27:46 2020 +0100 @@ -1,5 +1,6 @@ local statsman = require "core.statsmanager"; local st = require "util.stanza"; +local s_format = string.format; module:hook("iq/host/http://jabber.org/protocol/stats:query", function (event) local origin, stanza = event.origin, event.stanza; @@ -8,7 +9,7 @@ reply:tag("query", { xmlns = "http://jabber.org/protocol/stats" }); for stat, value in pairs(stats) do local unit = extra[stat] and extra[stat].units; - reply:tag("stat", { name = stat, unit = unit, value = tostring(value) }):up(); + reply:tag("stat", { name = stat, unit = unit, value = s_format("%.12g", value) }):up(); end origin.send(reply); return true;