<commit_before># Abstract implementation to get a list of channels
# subclass and implement get_alive_channels to return a list
# of ohm channel models

require_relative '../../util/can_can'

module Interactors
  module Channels
    class Index
      include Pavlov::Interactor
      include Util::CanCan

      def execute
        channels_with_authorities.map do |ch, authority|
          graph_user = channel_graph_user(ch)
          dead_user = dead_user_for_graph_user(graph_user)

          kill_channel(ch, authority, containing_channel_ids(ch), dead_user)
        end
      end

      def channel_graph_user(channel)
        channel.created_by
      end

      def dead_user_for_graph_user(graph_user)
        query(:users_by_ids, user_ids: [graph_user.user_id]).first
      end

      def channels_with_authorities
        authorities = query(:'creator_authorities_for_channels',
                                channels: visible_channels)<commit_msg>Use fetch with error per @markijbema's suggestion<commit_after># Abstract implementation to get a list of channels
# subclass and implement get_alive_channels to return a list
# of ohm channel models

require_relative '../../util/can_can'

module Interactors
  module Channels
    class Index
      include Pavlov::Interactor
      include Util::CanCan

      def execute
        channels_with_authorities.map do |ch, authority|
          graph_user = channel_graph_user(ch)
          dead_user = dead_user_for_graph_user(graph_user)

          kill_channel(ch, authority, containing_channel_ids(ch), dead_user)
        end
      end

      def channel_graph_user(channel)
        channel.created_by
      end

      def dead_user_for_graph_user(graph_user)
        query(:users_by_ids, user_ids: [graph_user.user_id])
          .fetch(0, :dead_user_for_graph_user_not_found)
      end

      def channels_with_authorities
        authorities = query(:'creator_authorities_for_channels',
                                channels: visible_channels)
{'fraction_non_alphanumeric': 0.060787244643746886, 'fraction_numerical': 0.0004982561036372695, 'mean_word_length': 2.88394584139265, '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': '1079863', 'n_tokens_mistral': 574, 'n_tokens_neox': 559, 'n_words': 137}