Files
leadchat/app/services/internal/remove_stale_redis_keys_service.rb
Vishnu Narayanan 9a405d65ba fix: RemoveStaleRedisKeys service (#10562)
Fixes issues with RemoveStaleRedisKeys service

Co-authored-by: Sojan <sojan@pepalo.com>
2024-12-11 03:38:25 +08:00

16 lines
541 B
Ruby

class Internal::RemoveStaleRedisKeysService
pattr_initialize [:account_id!]
def perform
Rails.logger.info "Removing redis stale keys for account #{@account_id}"
range_start = (Time.zone.now - OnlineStatusTracker::PRESENCE_DURATION).to_i
# exclusive minimum score is specified by prefixing (
# we are clearing old records because this could clogg up the sorted set
::Redis::Alfred.zremrangebyscore(
OnlineStatusTracker.presence_key(@account_id, 'Contact'),
'-inf',
"(#{range_start}"
)
end
end