From 551336f55f42f6fa635cb5498ed5a786156bc3ed Mon Sep 17 00:00:00 2001 From: Denver Gingerich Date: Mon, 20 Apr 2020 00:15:02 +0000 Subject: [PATCH] update log string, add todo, remove 'json' require Updated a log message to remove TODO as we won't be putting the ID of the message in the log, for privacy reasons. This also means that we won't have any need to read JSON anymore, so we can delete that "require 'json'" line as well. Added a TODO about handling another return value (of INCR). This probably isn't a big deal either way, as an INCR returning an error multiple times will result in duplicate archived_message keys that will be caught elsewhere, but there is still a small chance it won't be caught, so it would be good to fix eventually. --- r2s-bwmsgsv2.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/r2s-bwmsgsv2.rb b/r2s-bwmsgsv2.rb index a88487e9e95b7d778e788b50be1fde5b0ed5265e..20649a46894deeb8994da3f5632320cf4aeb5f51 100755 --- a/r2s-bwmsgsv2.rb +++ b/r2s-bwmsgsv2.rb @@ -20,7 +20,6 @@ require 'redis' require 'hiredis' require 'net/http' -require 'json' require 'time' $stdout.sync = true @@ -61,13 +60,14 @@ while true t = Time.now tai_timestamp = `./tai`.strip tai_yyyymmdd = Time.at(tai_timestamp.to_i).strftime('%Y%m%d') - puts "LOG %d.%09d, %s: msg [TODO: ID] sent on %s - incrementing\n" % + puts "LOG %d.%09d, %s: handling message sent on %s ...\n" % [t.to_i, t.nsec, tai_timestamp, tai_yyyymmdd] # WARNING: since not atomic with setex() below, translator is singleton day_msg_count = redis.incr( "archived_message-#{ARGV[0]}-#{tai_yyyymmdd}-total" ) + # TODO: confirm day_msg_count is integer > 0 (otherwise likely an error) t = Time.now puts "LOG %d.%09d: total msgs for %s-%s now at %s\n" %