class Comment < ApplicationRecord
belongs_to :post
belongs_to :author, class_name: "User"
validates :body, presence: true, length: { maximum: 5_000 }
class NotificationsChannel < ApplicationCable::Channel
def subscribed
stream_for current_user
end
def unsubscribed
<%= turbo_stream_from [current_member, :notifications] %>
<div id="notification_badge">
<%= render 'notifications/badge', count: current_member.notifications.unread.count %>
</div>
class ImportRun < ApplicationRecord
enum status: { pending: 0, running: 1, completed: 2, failed: 3 }
def percent
return 0 if total.to_i.zero?
[(processed.to_f / total * 100).round, 100].min
class PresenceRegistry
TTL = 30 # seconds a user counts as present without a heartbeat
def initialize(room_id, redis: REDIS)
@room_id = room_id
@redis = redis
class Comment < ApplicationRecord
belongs_to :post
belongs_to :author, class_name: "User"
validates :body, presence: true