<commit_before>module Queries
  # This query returns the list of channels for the
  # graph_user with graph_user_id which contain/follow
  # the channel with channel_id
  #
  # Since we cannot follow channels of ourselves in our own
  # channel we can directly return an empty list if we call
  # this for a channel of the graph_user
  class ContainingChannelIdsForChannelAndUser
    include Pavlov::Query
    arguments :channel_id, :graph_user_id

    def execute
      return [] if channel.created_by_id == @graph_user_id

      intersect_ids graph_user_channels, containing_channels
    end

    def graph_user_channels
      graph_user = GraphUser[@graph_user_id]
      ChannelList.new(graph_user).channels
    end

    def containing_channels
      channel.containing_channels
    end

    def channel
      @channel ||= Channel[@channel_id]
    end

    def intersect_ids channels1, channels2
      (channels1 & channels2).ids
    end
  end

end<commit_msg>rewrote query to use channel_list<commit_after>module Queries
  # This query returns the list of channels for the
  # graph_user with graph_user_id which contain/follow
  # the channel with channel_id
  #
  # Since we cannot follow channels of ourselves in our own
  # channel we can directly return an empty list if we call
  # this for a channel of the graph_user
  class ContainingChannelIdsForChannelAndUser
    include Pavlov::Query
    arguments :channel_id, :graph_user_id

    def execute
      return [] if channel.created_by_id == @graph_user_id

      channel_list.containing_channel_ids_for_channel channel
      intersect_ids graph_user_channels, containing_channels
    end

    def channel_list
      ChannelList.new(graph_user)
    end

    def graph_user
      GraphUser[@graph_user_id]
    end

    def channel
      @channel ||= Channel[@channel_id]
    end
  end

end
{'fraction_non_alphanumeric': 0.04378378378378378, 'fraction_numerical': 0.002162162162162162, 'mean_word_length': 3.3966745843230406, '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': '4742772', 'n_tokens_mistral': 532, 'n_tokens_neox': 517, 'n_words': 176}