<commit_before>module Concealable
  extend ActiveSupport::Concern

  included do
    enum privacy: {
      public: 0,
      private: 1,
      access_list: 2,
      full_accounts: 3,
      registered: 4,
    }, _prefix: true

    def visible_to?(user)
      # does not support access lists at this time
      return true if privacy_public?
      return false unless user
      return true if privacy_registered?
      return false if user.read_only?
      return true if privacy_full_accounts?
      return true if user.admin?
      user.id == user_id
    end
  end
end
<commit_msg>Add comments with context about new privacy enums<commit_after>module Concealable
  extend ActiveSupport::Concern

  included do
    # 3 used to be used as registered but was updated to full_accounts
    # with the release of read-only accounts to avoid a db migration.
    enum privacy: {
      public: 0,
      private: 1,
      access_list: 2,
      full_accounts: 3, # registered accounts that are not read-only
      registered: 4, # all registered accounts, both full and read-only
    }, _prefix: true

    def visible_to?(user)
      # does not support access lists at this time
      return true if privacy_public?
      return false unless user
      return true if privacy_registered?
      return false if user.read_only?
      return true if privacy_full_accounts?
      return true if user.admin?
      user.id == user_id
    end
  end
end

{'fraction_non_alphanumeric': 0.05365853658536585, 'fraction_numerical': 0.007665505226480836, 'mean_word_length': 2.6262626262626263, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3714583', 'n_tokens_mistral': 417, 'n_tokens_neox': 399, 'n_words': 161}