Remove unsbscribed domains from stats

parent 4afd5eed
Pipeline #355 failed with stage
in 27 seconds
......@@ -11,7 +11,10 @@ class PubRelay::Stats
record DeliveryCounterPayload,
counter : Int32
include Earl::Artist(HTTPResponsePayload | DeliveryPayload | DeliveryCounterPayload)
record UnsubscribePayload,
domain : String
include Earl::Artist(HTTPResponsePayload | DeliveryPayload | DeliveryCounterPayload | UnsubscribePayload)
@response_codes = Hash(String, Int32).new(default_value: 0)
@response_codes_per_domain = Hash(String, Hash(String, Int32)).new do |hash, key|
......@@ -48,6 +51,11 @@ class PubRelay::Stats
@latest_delivery = payload.counter
end
def call(unsubscribe : UnsubscribePayload)
@delivery_codes_per_domain.delete(unsubscribe.domain)
@latest_delivery_per_domain.delete(unsubscribe.domain)
end
def to_json(io)
{
response_codes: @response_codes,
......
......@@ -146,6 +146,8 @@ class PubRelay::SubscriptionManager
deliver_worker.stop
@redis.del(key_for(unsubscribe.domain))
@stats.send Stats::UnsubscribePayload.new(unsubscribe.domain)
end
def call(deliver : Deliver)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment