Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions profiles.lua
Original file line number Diff line number Diff line change
Expand Up @@ -486,3 +486,25 @@ function profile_print_specific_str_int_key_bit(key_id, bit_n)
bit_n
)
end

function profile_print_fields_length(min_field_len_kb)
if box.cfg.replication_source == nil then error("replica api only") end

profile_apply_func(
function (profile, min_field_len)
local to_print = ""
local total_bytes = 0
for pref_id, pref_value in pairs(profile.prefs) do
local l = pref_value:len()
if l >= min_field_len then
local key_id, _ = box.unpack('wa', pref_id)
to_print = to_print .. " " .. tostring(key_id) .. "=" .. tostring(l)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

better not to use string concatenation, but concat through table. Or use table.concat

end
total_bytes = total_bytes + l
end
if total_bytes then
print("FOUND: " .. tostring(profile_id_to_int(profile.id)) .. ": total=" .. tostring(total_bytes) .. to_print)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it will be too slow to print line for every user, it's better to print if total_bytes >= min_field_len: it will also check the case, when user has a lot of small fields, but their total size is huge.

end
end, min_field_len_kb * 1024
)
end