M .rubocop.yml => .rubocop.yml +3 -0
@@ 71,3 71,6 @@ Layout/IndentArray:
Style/FormatString:
EnforcedStyle: percent
+
+Style/FormatStringToken:
+ EnforcedStyle: unannotated
M sgx_jmp.rb => sgx_jmp.rb +16 -1
@@ 5,6 5,7 @@ require "bigdecimal"
require "blather/client/dsl" # Require this first to not auto-include
require "blather/client"
require "braintree"
+require "date"
require "dhall"
require "em-hiredis"
require "em_promise"
@@ 127,7 128,21 @@ end
message do |m|
Customer.for_jid(m.from.stripped).then { |customer|
- customer.stanza_from(m)
+ today = Time.now.utc.to_date
+ EMPromise.all([
+ REDIS.zremrangebylex(
+ "jmp_customer_outbound_messages-#{customer.customer_id}",
+ "-",
+ # Store message counts per day for 1 year
+ "[#{(today << 12).strftime('%Y%m%d')}"
+ ),
+ REDIS.zincrby(
+ "jmp_customer_outbound_messages-#{customer.customer_id}",
+ 1,
+ today.strftime("%Y%m%d")
+ ),
+ customer.stanza_from(m)
+ ])
}.catch(&method(:panic))
end