From 62c8cb8be4234db46ae27b160ccc5b8167df9a32 Mon Sep 17 00:00:00 2001 From: Thibaut Courouble Date: Sun, 16 Jul 2017 17:27:46 -0400 Subject: [PATCH] Log size difference of index.json and db.json --- lib/docs/subscribers/doc_subscriber.rb | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/docs/subscribers/doc_subscriber.rb b/lib/docs/subscribers/doc_subscriber.rb index 3e61bbdc..77386188 100644 --- a/lib/docs/subscribers/doc_subscriber.rb +++ b/lib/docs/subscribers/doc_subscriber.rb @@ -6,7 +6,9 @@ module Docs def index(event) before, after = parse_payload(event) - log "Entries: (#{(event.payload[:after].bytesize / 1.kilobyte.to_f).ceil} KB)" + size = event.payload[:after].bytesize + size_diff = size - event.payload[:before].bytesize + log "Entries: (#{(size / 1_000.0).ceil} KB, #{'+' if size_diff >= 0}#{(size_diff / 1_000.0).ceil} KB)" log_diff before['entries'], after['entries'], 'name' log "Types:" log_diff before['types'], after['types'], 'name' @@ -14,7 +16,9 @@ module Docs def db(event) before, after = parse_payload(event) - log "Files: (#{(event.payload[:after].bytesize / 1.megabyte.to_f).ceil(1)} MB)" + size = event.payload[:after].bytesize + size_diff = size - event.payload[:before].bytesize + log "Files: (#{(size / 1_000_000.0).ceil(1)} MB, #{'+' if size_diff >= 0}#{(size_diff / 1_000_000.0).ceil(1)} MB)" log_diff before.keys, after.keys end