Skip to content

Commit

Permalink
Revert "Introduce search_streams in EventRepository"
Browse files Browse the repository at this point in the history
This reverts commit e930fbf.
  • Loading branch information
lukaszreszke committed Jul 25, 2024
1 parent 7d86caa commit 7b59b9c
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 59 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,6 @@ def count(specification)
@repo_reader.count(specification)
end

def search_streams(stream_name)
@repo_reader.search_streams(stream_name)
end

def update_messages(records)
hashes = records.map { |record| upsert_hash(record, record.serialize(serializer)) }
for_update = records.map(&:event_id)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,6 @@ def event_in_stream?(event_id, stream)
@stream_klass.where(event_id: event_id, stream: stream.name).exists?
end

def search_streams(stream)
@stream_klass.where("stream LIKE ?", "#{stream}%").pluck(:stream).uniq
end

private

attr_reader :serializer
Expand Down
51 changes: 0 additions & 51 deletions ruby_event_store-active_record/spec/event_repository_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -183,57 +183,6 @@ module ActiveRecord
expect(event_record.valid_at).to eq(t2)
end

specify "finds streams that match the search phrase" do
repository.append_to_stream(
[SRecord.new(event_id: e1 = SecureRandom.uuid)],
Stream.new("Dummy$#{e1}"),
ExpectedVersion.any
)
repository.append_to_stream(
[SRecord.new(event_id: e2 = SecureRandom.uuid)],
Stream.new("Dummy$#{e2}"),
ExpectedVersion.any
)
repository.append_to_stream(
[SRecord.new(event_id: e3 = SecureRandom.uuid)],
Stream.new("Dummy$#{e3}"),
ExpectedVersion.any
)

expect(repository.search_streams("Du")).to eq(["Dummy$#{e1}", "Dummy$#{e2}", "Dummy$#{e3}"])
expect(repository.search_streams("du")).to eq(["Dummy$#{e1}", "Dummy$#{e2}", "Dummy$#{e3}"])
expect(repository.search_streams("dum")).to eq(["Dummy$#{e1}", "Dummy$#{e2}", "Dummy$#{e3}"])
expect(repository.search_streams("dumm")).to eq(["Dummy$#{e1}", "Dummy$#{e2}", "Dummy$#{e3}"])
expect(repository.search_streams("dummy")).to eq(["Dummy$#{e1}", "Dummy$#{e2}", "Dummy$#{e3}"])
expect(repository.search_streams("Dummy")).to eq(["Dummy$#{e1}", "Dummy$#{e2}", "Dummy$#{e3}"])
end

specify "finds no streams when search phrase doesn't match anything" do
repository.append_to_stream(
[SRecord.new(event_id: e1 = SecureRandom.uuid)],
Stream.new("Dummy$#{e1}"),
ExpectedVersion.any
)
repository.append_to_stream(
[SRecord.new(event_id: e2 = SecureRandom.uuid)],
Stream.new("Dummy$#{e2}"),
ExpectedVersion.any
)
repository.append_to_stream(
[SRecord.new(event_id: e3 = SecureRandom.uuid)],
Stream.new("Dummy$#{e3}"),
ExpectedVersion.any
)

expect(repository.search_streams("Da")).to eq([])
expect(repository.search_streams("da")).to eq([])
expect(repository.search_streams("dam")).to eq([])
expect(repository.search_streams("damm")).to eq([])
expect(repository.search_streams("dammy")).to eq([])
expect(repository.search_streams("Dammy")).to eq([])
end


specify "with batches and bi-temporal queries use offset + limit" do
repository.append_to_stream(
[
Expand Down

0 comments on commit 7b59b9c

Please sign in to comment.