Send raw integer bytes_transferred to backup_runs
The datatable column is type number, so the human-formatted string
('20.96 KB') was rejected with a validation error (seen on the first
vaultwarden-org-export report). Format for display in the reporter,
not in the payload. Deployed copy in ~/.local/bin updated to match.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0133oyd1U9XxpLQU3UHMzUyy
This commit is contained in:
parent
f9579e925f
commit
79f4825e4b
|
|
@ -69,7 +69,9 @@ class PayloadBuilder
|
||||||
machine: @options[:machine],
|
machine: @options[:machine],
|
||||||
destination: @options[:destination],
|
destination: @options[:destination],
|
||||||
status: @options[:status],
|
status: @options[:status],
|
||||||
bytes_transferred: ByteFormatter.format(@options[:bytes]),
|
# Raw integer: the backup_runs datatable column is type number;
|
||||||
|
# human formatting belongs in the reporter, not the payload.
|
||||||
|
bytes_transferred: @options[:bytes],
|
||||||
snapshot_id: @options[:snapshot],
|
snapshot_id: @options[:snapshot],
|
||||||
log_path: @options[:log_path],
|
log_path: @options[:log_path],
|
||||||
notes: @options[:notes]
|
notes: @options[:notes]
|
||||||
|
|
|
||||||
|
|
@ -43,9 +43,9 @@ class PayloadBuilderTest < Minitest::Test
|
||||||
assert_match(/\A\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z\z/, payload[:timestamp])
|
assert_match(/\A\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z\z/, payload[:timestamp])
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_formats_bytes_to_human_readable
|
def test_sends_raw_integer_bytes
|
||||||
payload = PayloadBuilder.new(base_options.merge(bytes: 1_073_741_824)).build
|
payload = PayloadBuilder.new(base_options.merge(bytes: 1_073_741_824)).build
|
||||||
assert_equal '1.00 GB', payload[:bytes_transferred]
|
assert_equal 1_073_741_824, payload[:bytes_transferred]
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_omits_nil_optional_fields
|
def test_omits_nil_optional_fields
|
||||||
|
|
@ -64,7 +64,7 @@ class PayloadBuilderTest < Minitest::Test
|
||||||
notes: 'snapshot abc12345 saved'
|
notes: 'snapshot abc12345 saved'
|
||||||
)
|
)
|
||||||
payload = PayloadBuilder.new(opts).build
|
payload = PayloadBuilder.new(opts).build
|
||||||
assert_equal '1.00 MB', payload[:bytes_transferred]
|
assert_equal 1_048_576, payload[:bytes_transferred]
|
||||||
assert_equal 'abc12345', payload[:snapshot_id]
|
assert_equal 'abc12345', payload[:snapshot_id]
|
||||||
assert_equal '/home/jared/.local/log/restic/2026-05-07.log', payload[:log_path]
|
assert_equal '/home/jared/.local/log/restic/2026-05-07.log', payload[:log_path]
|
||||||
assert_equal 'snapshot abc12345 saved', payload[:notes]
|
assert_equal 'snapshot abc12345 saved', payload[:notes]
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue