<commit_before>require 'active_record'

module RailsEventStoreActiveRecord
  class LegacyEventRepository
    class LegacyEvent < ::ActiveRecord::Base
      self.primary_key = :id
      self.table_name = 'event_store_events'
      serialize :metadata
      serialize :data
    end

    private_constant :LegacyEvent

    def append_to_stream(events, stream_name, expected_version)
      [*events].map do |event|
        data = event.to_h.merge!(stream: stream_name, event_type: event.class)
        LegacyEvent.create!(data)
      end
      self
    end

    def delete_stream(stream_name)
      LegacyEvent.where({stream: stream_name}).destroy_all
    end

    def has_event?(event_id)
      LegacyEvent.exists?(event_id: event_id)
    end
<commit_msg>Support removal from stream in legacy event repository<commit_after>require 'active_record'

module RailsEventStoreActiveRecord
  class LegacyEventRepository
    class LegacyEvent < ::ActiveRecord::Base
      self.primary_key = :id
      self.table_name = 'event_store_events'
      serialize :metadata
      serialize :data
    end

    private_constant :LegacyEvent

    def append_to_stream(events, stream_name, expected_version)
      [*events].map do |event|
        data = event.to_h.merge!(stream: stream_name, event_type: event.class)
        LegacyEvent.create!(data)
      end
      self
    end

    def delete_stream(stream_name)
      LegacyEvent.where({stream: stream_name}).update_all(stream: RubyEventStore::GLOBAL_STREAM)
    end

    def has_event?(event_id)
      LegacyEvent.exists?(event_id: event_id)
    end

{'fraction_non_alphanumeric': 0.08022741629816804, 'fraction_numerical': 0.0, 'mean_word_length': 3.4619718309859153, 'pattern_counts': {'":': 0, '<': 5, '<?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': '5330447', 'n_tokens_mistral': 483, 'n_tokens_neox': 467, 'n_words': 100}