<commit_before># frozen_string_literal: true

module EpisodeRecordListSettable
  extend ActiveSupport::Concern

  def set_episode_record_list(episode)
    records = episode.records
      .only_kept
      .preload(:work, :work_record, episode_record: :episode)
      .eager_load(user: %i[gumroad_subscriber profile setting])
      .merge(EpisodeRecord.with_body.order_by_rating_state(:desc).order(created_at: :desc))
    @my_records = @following_records = Record.none

    if user_signed_in?
      records = records.where.not(user_id: current_user.mute_users.pluck(:muted_user_id))
      @my_records = current_user
        .records
        .only_kept
        .eager_load(:episode_record)
        .where(episode_records: {episode_id: episode.id})
        .order(created_at: :desc)
      @following_records = records.merge(current_user.followings)
      @all_records = records.where.not(user: [current_user, *current_user.followings]).page(params[:page]).per(20)
    else
      @all_records = records.page(params[:page]).per(20)
    end
  end
end<commit_msg>エピソードページの記録取得処理を調整<commit_after># frozen_string_literal: true

module EpisodeRecordListSettable
  extend ActiveSupport::Concern

  def set_episode_record_list(episode)
    records = episode
      .records
      .preload(:work, episode_record: :episode)
      .eager_load(user: %i[gumroad_subscriber profile setting])
      .only_kept
      .merge(EpisodeRecord.order_by_rating_state(:desc))
      .order(watched_at: :desc)
    @my_records = @following_records = Record.none

    if user_signed_in?
      records = records
        .where.not(user_id: current_user.mute_users.pluck(:muted_user_id))
      @my_records = current_user
        .records
        .eager_load(:episode_record)
        .only_kept
        .where(episode_records: {episode_id: episode.id})
        .order(watched_at: :desc)
      @following_records = records
        .merge(current_user.followings)
      @all_records = records
         .where.not(user: [current_user, *current_user.followings])
    else
      @all_records = records
    end

    @all_records = @all_records
      .merge(EpisodeRecord.with_body)
      .page(params[:page])
      .per(20)
  end
end
{'fraction_non_alphanumeric': 0.1045662100456621, 'fraction_numerical': 0.0027397260273972603, 'mean_word_length': 3.4714285714285715, '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': 5, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1083759', 'n_tokens_mistral': 757, 'n_tokens_neox': 736, 'n_words': 112}