Files
fizzy/app/models/access.rb
T
Donal McBreen fc56ad9d7c Combine uuid-old and uuid branch changes
- Switch to binary 16 for UUID keys
- Remove AccountScopedRecord base class, all model use binary uuids now
- Fix the search sql to serialize uuids properly
- Patch the MySQL schema dumper to output binary lengths
2025-11-17 09:12:34 -05:00

24 lines
585 B
Ruby

class Access < ApplicationRecord
belongs_to :board, touch: true
belongs_to :user, touch: true
enum :involvement, %i[ access_only watching ].index_by(&:itself), default: :access_only
scope :ordered_by_recently_accessed, -> { order(accessed_at: :desc) }
after_destroy_commit :clean_inaccessible_data_later
def accessed
touch :accessed_at unless recently_accessed?
end
private
def recently_accessed?
accessed_at&.> 5.minutes.ago
end
def clean_inaccessible_data_later
Board::CleanInaccessibleDataJob.perform_later(user, board)
end
end