<commit_before>module Repository::Access

  extend ActiveSupport::Concern

  OPTIONS = %w[private public_r public_rw]

  included do
    scope :pub, where("access != 'private'")
    scope :accessible_by, ->(user) do
      if user
        where("access != 'private'
          OR id IN (SELECT item_id FROM permissions WHERE item_type = 'Repository' AND subject_type = 'User' AND subject_id = ?)
          OR id IN (SELECT item_id FROM permissions INNER JOIN team_users ON team_users.team_id = permissions.subject_id AND team_users.user_id = ?
            WHERE  item_type = 'Repository' AND subject_type = 'Team')", user, user)
      else
        pub
      end
    end

    validates :access,
      presence: true,
      inclusion: { in: Repository::Access::OPTIONS }
  end

  def is_private
    access == 'private'
  end

  def public_rw?
    access == 'public_rw'
  end
  
  private

  def clear_readers<commit_msg>add the missing public_r method.<commit_after>module Repository::Access

  extend ActiveSupport::Concern

  OPTIONS = %w[private public_r public_rw]

  included do
    scope :pub, where("access != 'private'")
    scope :accessible_by, ->(user) do
      if user
        where("access != 'private'
          OR id IN (SELECT item_id FROM permissions WHERE item_type = 'Repository' AND subject_type = 'User' AND subject_id = ?)
          OR id IN (SELECT item_id FROM permissions INNER JOIN team_users ON team_users.team_id = permissions.subject_id AND team_users.user_id = ?
            WHERE  item_type = 'Repository' AND subject_type = 'Team')", user, user)
      else
        pub
      end
    end

    validates :access,
      presence: true,
      inclusion: { in: Repository::Access::OPTIONS }
  end

  def is_private
    access == 'private'
  end

  def public_rw?
    access == 'public_rw'
  end

  def public_r?
    access == 'public_r'
  end
  
  private

  def clear_readers
{'fraction_non_alphanumeric': 0.08952080042127436, 'fraction_numerical': 0.0, 'mean_word_length': 2.8383838383838382, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '2622849', 'n_tokens_mistral': 593, 'n_tokens_neox': 573, 'n_words': 178}