require "lua_utils"
local format_utils = require "format_utils"
-- Get from redis the throughput type bps or pps
local throughput_type = getThroughputType()
local now = os.time()
function country2record(ifId, country)
local record = {}
record["key"] = tostring(country["country"])
local country_link = ""..country["country"]..''
record["column_id"] = getFlag(country["country"]).."  " .. country_link
record["column_score"] = format_high_num_value_for_tables(country, "score")
record["column_hosts"] = format_high_num_value_for_tables(country, "num_hosts")
record["column_since"] = secondsToTime(now - country["seen.first"] + 1)
local sent2rcvd = round((country["egress"] * 100) / (country["egress"] + country["ingress"]), 0)
record["column_breakdown"] = format_utils.createBreakdown(sent2rcvd, 100 - sent2rcvd, "Sent", "Rcvd")
if(throughput_type == "pps") then
record["column_thpt"] = pktsToSize(country["throughput_pps"])
else
record["column_thpt"] = bitsToSize(8*country["throughput_bps"])
end
record["column_traffic"] = bytesToSize(country["bytes"])
record["column_chart"] = ""
if areCountryTimeseriesEnabled(ifId) then
record["column_chart"] = ''
end
return record
end