<commit_before># frozen_string_literal: true

RSpec.describe ROM::Relation, "#combine_with" do
  include_context "gateway only"
  include_context "users and tasks"

  let(:tags_dataset) { gateway.dataset(:tags) }

  let(:users_relation) do
    Class.new(ROM::Memory::Relation) do
      config.auto_map = false

      schema(:users) {}

      def by_name(name)
        restrict(name: name)
      end
    end.new(users_dataset)
  end

  let(:tasks_relation) do
    Class.new(ROM::Memory::Relation) do
      config.auto_map = false

      schema(:tasks) {}

      def for_users(users)
        names = users.map { |user| user[:name] }
        restrict { |task| names.include?(task[:name]) }
      end
    end.new(tasks_dataset)
  end

  let(:tags_relation) do
    Class.new(ROM::Memory::Relation) do
      config.auto_map = false

      schema(:tags) {}

      attr_accessor :tasks
      forward :map

      def for_tasks(tasks)
        titles = tasks.map { |task| task[:title] }
        restrict { |tag| titles.include?(tag[:task]) }<commit_msg>[rubocop] address Layout/EmptyLinesAroundAttributeAccessor<commit_after># frozen_string_literal: true

RSpec.describe ROM::Relation, "#combine_with" do
  include_context "gateway only"
  include_context "users and tasks"

  let(:tags_dataset) { gateway.dataset(:tags) }

  let(:users_relation) do
    Class.new(ROM::Memory::Relation) do
      config.auto_map = false

      schema(:users) {}

      def by_name(name)
        restrict(name: name)
      end
    end.new(users_dataset)
  end

  let(:tasks_relation) do
    Class.new(ROM::Memory::Relation) do
      config.auto_map = false

      schema(:tasks) {}

      def for_users(users)
        names = users.map { |user| user[:name] }
        restrict { |task| names.include?(task[:name]) }
      end
    end.new(tasks_dataset)
  end

  let(:tags_relation) do
    Class.new(ROM::Memory::Relation) do
      config.auto_map = false

      schema(:tags) {}

      attr_accessor :tasks

      forward :map

      def for_tasks(tasks)
        titles = tasks.map { |task| task[:title] }
        restrict { |tag| titles.include?(tag[:task]) }
{'fraction_non_alphanumeric': 0.12629107981220658, 'fraction_numerical': 0.0, 'mean_word_length': 2.968342644320298, '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': '2225520', 'n_tokens_mistral': 705, 'n_tokens_neox': 685, 'n_words': 140}