<commit_before>require_relative 'channel/activities'

class Channel < OurOhm
  include Activity::Subject

  attribute :title
  index :title

  attribute :lowercase_title

  attribute :slug_title
  index :slug_title

  def create
    result = super

    Topic.get_or_create_by_channel(self)

    result
  end

  alias :old_set_title :title= unless method_defined?(:old_set_title)
  def title=(new_title)
    old_set_title new_title
    self.lowercase_title = new_title.downcase
    self.slug_title = new_title.to_url
  end

  def save
    self.title = self.title
    super
  end

  reference :created_by, GraphUser
  alias :graph_user :created_by
  index :created_by_id

  set :contained_channels, Channel
  set :containing_channels, Channel

  set :unread_facts, Channel

  timestamped_set :sorted_internal_facts, Fact
  timestamped_set :sorted_delete_facts, Fact
  timestamped_set :sorted_cached_facts, Fact

  def delete
    contained_channels.each do |subch|
      subch.containing_channels.delete self
    end
    containing_channels.each do |ch|
      ch.contained_channels.delete self
    end
    Activity.for(self).each do |a|
      a.delete
    end
    super
  end

  def channel_facts
    ChannelFacts.new(self)
  end
  private :channel_facts
  delegate :mark_as_read, :facts, :remove_fact, :include?,
           :to => :channel_facts

  def validate
    result = super

    assert_present :title
    assert_present :slug_title
    assert_present :created_by
    assert_unique([:slug_title,:created_by_id])

    result
  end

  def to_s
    title
  end

  def add_channel(channel)
    return false if contained_channels.include?(channel)

    contained_channels << channel
    channel.containing_channels << self
    true
  end

  def remove_channel(channel)
    return false unless contained_channels.include?(channel)

    contained_channels.delete(channel)
    channel.containing_channels.delete(self)
    true
  end

  def containing_channels_for_ids(user)
    []
  end

  def topic
    Topic.get_or_create_by_channel self
  end
end<commit_msg>Removed no longer used functionality<commit_after>require_relative 'channel/activities'

class Channel < OurOhm
  include Activity::Subject

  attribute :title
  index :title

  attribute :lowercase_title

  attribute :slug_title
  index :slug_title

  def create
    result = super

    Topic.get_or_create_by_channel(self)

    result
  end

  alias :old_set_title :title= unless method_defined?(:old_set_title)
  def title=(new_title)
    old_set_title new_title
    self.lowercase_title = new_title.downcase
    self.slug_title = new_title.to_url
  end

  def save
    self.title = self.title
    super
  end

  reference :created_by, GraphUser
  alias :graph_user :created_by
  index :created_by_id

  set :contained_channels, Channel
  set :containing_channels, Channel

  set :unread_facts, Channel

  timestamped_set :sorted_internal_facts, Fact
  timestamped_set :sorted_delete_facts, Fact
  timestamped_set :sorted_cached_facts, Fact

  def delete
    Activity.for(self).each do |a|
      a.delete
    end
    super
  end

  def channel_facts
    ChannelFacts.new(self)
  end
  private :channel_facts
  delegate :mark_as_read, :facts, :remove_fact, :include?,
           :to => :channel_facts

  def validate
    result = super

    assert_present :title
    assert_present :slug_title
    assert_present :created_by
    assert_unique([:slug_title,:created_by_id])

    result
  end

  def to_s
    title
  end

  def topic
    Topic.get_or_create_by_channel self
  end
end
{'fraction_non_alphanumeric': 0.061581920903954805, 'fraction_numerical': 0.0, 'mean_word_length': 3.5631443298969074, 'pattern_counts': {'":': 0, '<': 9, '<?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': '3284865', 'n_tokens_mistral': 1190, 'n_tokens_neox': 1124, 'n_words': 270}