<commit_before># frozen_string_literal: true

module Api
  module V1
    module Me
      class ProgramIndexService < Api::V1::BaseService
        attr_writer :user

        def result
          @collection = filter_unwatched
          @collection = filter_ids
          @collection = filter_channel_ids
          @collection = filter_work_ids
          @collection = filter_started_at_gt
          @collection = filter_started_at_lt
          @collection = filter_rebroadcast
          @collection = sort_id
          @collection = sort_started_at
          @collection = @collection.page(@params.page).per(@params.per_page)
          @collection
        end

        private

        def filter_unwatched
          unwatched = @params.filter_unwatched
          return @collection if unwatched.blank? || unwatched == "false"
          @user.programs.unwatched_all.work_published.episode_published
        end

        def filter_channel_ids
          return @collection if @params.filter_channel_ids.blank?
          @collection.where(channel_id: @params.filter_channel_ids)<commit_msg>Revert "unwatched -> unwatched_all"<commit_after># frozen_string_literal: true

module Api
  module V1
    module Me
      class ProgramIndexService < Api::V1::BaseService
        attr_writer :user

        def result
          @collection = filter_unwatched
          @collection = filter_ids
          @collection = filter_channel_ids
          @collection = filter_work_ids
          @collection = filter_started_at_gt
          @collection = filter_started_at_lt
          @collection = filter_rebroadcast
          @collection = sort_id
          @collection = sort_started_at
          @collection = @collection.page(@params.page).per(@params.per_page)
          @collection
        end

        private

        def filter_unwatched
          unwatched = @params.filter_unwatched
          return @collection if unwatched.blank? || unwatched == "false"
          @user.programs.unwatched.work_published.episode_published
        end

        def filter_channel_ids
          return @collection if @params.filter_channel_ids.blank?
          @collection.where(channel_id: @params.filter_channel_ids)
{'fraction_non_alphanumeric': 0.06751824817518248, 'fraction_numerical': 0.0018248175182481751, 'mean_word_length': 2.4105754276827374, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 4, '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': '5649542', 'n_tokens_mistral': 597, 'n_tokens_neox': 585, 'n_words': 119}