<commit_before>class ChannelManager
  def initialize(gu)
    @gu = gu
  end

  def editable_channels(limit=nil)
    @channels = @gu.channels.to_a
    # TODO: wtf?
    @username = @gu.user.username
    @channels = @channels.reject! { |channel| ! channel.editable? }

    limit ? @channels[0..limit] : @channels
  end

  def editable_channels_by_authority(gu, limit=nil)
    auth = {}

    @channels = editable_channels

    @channels = @channels.to_a.sort do |a, b|
      topic_a = Topic.by_title(a.title)
      topic_b = Topic.by_title(b.title)

      if topic_a.new?
        topic_a.save
      end

      if topic_b.new?
        topic_b.save
      end

      auth[topic_a.id] ||= Authority.from(topic_a, for: gu).to_f
      auth[topic_b.id] ||= Authority.from(topic_b, for: gu).to_f

      auth[topic_b.id] <=> auth[topic_a.id]
    end

    limit ? @channels[0..limit] : @channels
  end

  def editable_channels_for(fact)
    channels = editable_channels
    # TODO: wtf continued; dirty shit with @username
    channels.map {|ch| ChannelForFact.new(ch,fact,@username)}
  end

  def containing_channel_ids(fact)
    @channels = @gu.channels.to_a
    @channels.select { |ch| ch.include? fact }.map{ |ch| ch.id }
  end<commit_msg>shortened<commit_after>class ChannelManager
  def initialize(gu)
    @gu = gu
  end

  def editable_channels(limit=nil)
    @channels = @gu.channels.to_a
    # TODO: wtf?
    @username = @gu.user.username
    @channels = @channels.reject! { |channel| ! channel.editable? }

    limit ? @channels[0..limit] : @channels
  end

  def editable_channels_by_authority(gu, limit=nil)
    auth = {}

    @channels = editable_channels

    @channels = @channels.to_a.sort do |a, b|
      topic_a = Topic.by_title(a.title)
      topic_b = Topic.by_title(b.title)

      topic_a.save if topic_a.new?
      topic_b.save if topic_b.new?

      auth[topic_a.id] ||= Authority.from(topic_a, for: gu).to_f
      auth[topic_b.id] ||= Authority.from(topic_b, for: gu).to_f

      auth[topic_b.id] <=> auth[topic_a.id]
    end

    limit ? @channels[0..limit] : @channels
  end

  def editable_channels_for(fact)
    channels = editable_channels
    # TODO: wtf continued; dirty shit with @username
    channels.map {|ch| ChannelForFact.new(ch,fact,@username)}
  end

  def containing_channel_ids(fact)
    @channels = @gu.channels.to_a
    @channels.select { |ch| ch.include? fact }.map{ |ch| ch.id }
  end
{'fraction_non_alphanumeric': 0.12908564335953662, 'fraction_numerical': 0.0016549441456350847, 'mean_word_length': 3.03, 'pattern_counts': {'":': 0, '<': 5, '<?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': 2, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6941519', 'n_tokens_mistral': 893, 'n_tokens_neox': 869, 'n_words': 173}