Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

revert search streams and debug experiments #1793

Merged
merged 42 commits into from
Aug 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
202b9d3
Revert "Do not assert specific adapter being used"
lukaszreszke Jul 25, 2024
1ae2c92
Revert "specification -> inspect, repository_specification -> inspect…
lukaszreszke Jul 25, 2024
64c4ed6
Revert "One more formatter round"
lukaszreszke Jul 25, 2024
2811536
Revert "formatting"
lukaszreszke Jul 25, 2024
bfd0bd0
Revert "Add total events counter to the debug page"
lukaszreszke Jul 25, 2024
09f1a55
Revert "Format Page.Debug"
lukaszreszke Jul 25, 2024
bd9d19e
Revert "Format Main"
lukaszreszke Jul 25, 2024
3715b43
Revert "Format Route"
lukaszreszke Jul 25, 2024
dd443df
Revert "add order to rom"
lukaszreszke Jul 25, 2024
3040d94
Revert "Search streams for sequel"
lukaszreszke Jul 25, 2024
d31e737
Revert "Implement search_streams in ROM"
lukaszreszke Jul 25, 2024
1a69872
Revert "Add debug url to the browser layout"
lukaszreszke Jul 25, 2024
02dcfb5
Revert "Adjust test"
lukaszreszke Jul 25, 2024
d14ba04
Revert "We don't mind the order"
lukaszreszke Jul 25, 2024
04a8469
Revert "adjust tests"
lukaszreszke Jul 25, 2024
5654055
Revert "Optimize querys performance"
lukaszreszke Jul 25, 2024
851c723
Revert "test if InstrumentedRepository presents which repository is i…
lukaszreszke Jul 25, 2024
7cde0ae
Revert "present which exactly repository is instrumented"
lukaszreszke Jul 25, 2024
6919b65
Revert "prettier"
lukaszreszke Jul 25, 2024
398c2cd
Revert "test if /debug page is served"
lukaszreszke Jul 25, 2024
3891166
Revert "test if repositoryAdapter flag is set"
lukaszreszke Jul 25, 2024
e3db794
Revert "move `repository_specification` method to the proper class"
lukaszreszke Jul 25, 2024
58e31c3
Revert "Kill mutants"
lukaszreszke Jul 25, 2024
a17731c
Revert "Limit number of searched streams to 10"
lukaszreszke Jul 25, 2024
04b5a0c
Revert "Add repositoryAdapter eml flag"
lukaszreszke Jul 25, 2024
af36acb
Revert "Debug module with its own model"
lukaszreszke Jul 25, 2024
edeebb0
Revert "move Debug page to separate module"
lukaszreszke Jul 25, 2024
0e7183d
Revert "initiate /debug browser page"
lukaszreszke Jul 25, 2024
4a54baf
Revert "Kill mutant"
lukaszreszke Jul 25, 2024
4c5d3be
Revert "lowercase"
lukaszreszke Jul 25, 2024
220f38b
Revert "search streams endpoint for browser"
lukaszreszke Jul 25, 2024
b6a1e5a
Revert "Add search_streams in RubyEventStore::Client"
lukaszreszke Jul 25, 2024
0c059a7
Revert "Add search_streams to InMemoryRepository"
lukaszreszke Jul 25, 2024
45714f8
Revert "Add search_streams test into event_repository_lint"
lukaszreszke Jul 25, 2024
aed52a0
Revert "Reverse results order"
lukaszreszke Jul 25, 2024
7d86caa
Revert "Return stream object instead of name"
lukaszreszke Jul 25, 2024
7b59b9c
Revert "Introduce search_streams in EventRepository"
lukaszreszke Jul 25, 2024
c653326
Revert "Show real repository adapter on Debug page"
lukaszreszke Jul 25, 2024
e470c8f
Remove search streams left overs
lukaszreszke Jul 25, 2024
fbdad5d
Revert bookmarks
lukaszreszke Jul 25, 2024
442e272
format
lukaszreszke Jul 25, 2024
b18b6b8
Rename
lukaszreszke Jul 25, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,6 @@ def streams_of(event_id)
@stream_entries.streams_of(event_id).map { |name| Stream.new(name) }
end

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

private

def validate_event_ids(event_ids)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,6 @@ def position_in_stream(event_id, stream)
def event_in_stream?(event_id, stream)
stream_entries.by_stream(stream).by_event_id(event_id).exist?
end

def search_streams(stream_name)
stream_entries
.where { stream.like("#{stream_name}%") }
.distinct
.limit(10)
.order(:stream)
.pluck(:stream)
.map { |name| Stream.new(name) }
end
end
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,14 +172,6 @@ def streams_of(event_id)
@db[:event_store_events_in_streams].where(event_id: event_id).map { |h| Stream.new(h[:stream]) }
end

def search_streams(stream_name)
@db[:event_store_events_in_streams]
.where(::Sequel.like(:stream, "#{stream_name}%"))
.select(:stream)
.limit(10)
.map { |h| Stream.new(h[:stream]) }
end

private

def optimize_timestamp(valid_at, created_at)
Expand Down
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 Expand Up @@ -85,10 +81,6 @@ def event_in_stream?(event_id, stream)
@repo_reader.event_in_stream?(event_id, stream)
end

def inspect
"#{self.class} with #{::ActiveRecord::Base.connection.adapter_name} db adapter"
end

private

attr_reader :serializer
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +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}%")
.limit(10)
.pluck("distinct stream")
.map { |name| Stream.new(name) }
end

private

attr_reader :serializer
Expand Down
65 changes: 0 additions & 65 deletions ruby_event_store-active_record/spec/event_repository_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -183,65 +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)],
s1 = Stream.new("Dummy$#{e1}"),
ExpectedVersion.any
)
repository.append_to_stream(
[SRecord.new(event_id: e2 = SecureRandom.uuid)],
s2 = Stream.new("Dummy$#{e2}"),
ExpectedVersion.any
)
repository.append_to_stream(
[SRecord.new(event_id: e3 = SecureRandom.uuid)],
s3 = Stream.new("Dummy$#{e3}"),
ExpectedVersion.any
)

expect(repository.search_streams("Du")).to contain_exactly(s3, s2, s1)
expect(repository.search_streams("Dummy")).to contain_exactly(s3, s2, s1)
end

specify "limits searched streams to 10" do
11.times do |index|
repository.append_to_stream(
[SRecord.new(event_id: e1 = SecureRandom.uuid)],
Stream.new("Dummy$#{e1}"),
ExpectedVersion.any
)
end

expect(repository.search_streams("Du").size).to eq 10
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 Expand Up @@ -378,12 +319,6 @@ module ActiveRecord
}x
end

describe "#inspect" do
specify "returns string representation" do
expect(repository.inspect).to eq("RubyEventStore::ActiveRecord::EventRepository with #{::ActiveRecord::Base.connection.adapter_name} db adapter")
end
end

private

def with_precision(time)
Expand Down
60 changes: 2 additions & 58 deletions ruby_event_store-browser/elm/src/Api.elm
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
module Api exposing (Event, PaginatedList, PaginationLink, PaginationLinks, RemoteResource(..), SearchStream, Stats, Stream, emptyPaginatedList, eventDecoder, eventsDecoder, getEvent, getEvents, getSearchStreams, getStats, getStream, searchStreamsDecoder)
module Api exposing (Event, PaginatedList, PaginationLink, PaginationLinks, RemoteResource(..), Stream, emptyPaginatedList, eventDecoder, eventsDecoder, getEvent, getEvents, getStream)

import Flags exposing (Flags)
import Http
import Iso8601
import Json.Decode exposing (Decoder, field, int, list, maybe, string, succeed, value)
import Json.Decode exposing (Decoder, field, list, maybe, string, succeed, value)
import Json.Decode.Pipeline exposing (optional, optionalAt, required, requiredAt)
import Json.Encode exposing (encode)
import Maybe.Extra
Expand Down Expand Up @@ -38,15 +38,6 @@ type alias Event =
}


type alias SearchStream =
{ streamId : String
}


type alias Stats =
{ eventsInTotal : Int
}


type alias PaginatedList a =
{ pagination : Pagination.Specification
Expand Down Expand Up @@ -94,15 +85,6 @@ streamUrl flags streamId =
buildUrl (Url.toString flags.apiUrl ++ "/streams") streamId


searchStreamsUrl : Flags -> String -> String
searchStreamsUrl flags query =
buildUrl (Url.toString flags.apiUrl ++ "/search_streams") query


getStatsUrl : Flags -> String
getStatsUrl flags =
Url.toString flags.apiUrl ++ "/stats"


getEvent : (Result Http.Error Event -> msg) -> Flags -> String -> Cmd msg
getEvent msgBuilder flags eventId =
Expand All @@ -120,21 +102,6 @@ getStream msgBuilder flags streamId =
}


getSearchStreams : (Result Http.Error (List SearchStream) -> msg) -> Flags -> String -> Cmd msg
getSearchStreams msgBuilder flags query =
Http.get
{ url = searchStreamsUrl flags query
, expect = Http.expectJson msgBuilder searchStreamsDecoder
}


getStats : (Result Http.Error Stats -> msg) -> Flags -> Cmd msg
getStats msgBuilder flags =
Http.get
{ url = getStatsUrl flags
, expect = Http.expectJson msgBuilder statsDecoder
}


eventDecoder : Decoder Event
eventDecoder =
Expand Down Expand Up @@ -190,29 +157,6 @@ eventsDecoder pagination =
|> required "links" linksDecoder


searchStreamDecoder : Decoder SearchStream
searchStreamDecoder =
succeed SearchStream
|> required "id" string


searchStreamsDecoder : Decoder (List SearchStream)
searchStreamsDecoder =
list searchStreamDecoder
|> field "data"


statsDecoder : Decoder Stats
statsDecoder =
statsDecoder_
|> field "meta"


statsDecoder_ : Decoder Stats
statsDecoder_ =
succeed Stats
|> required "events_in_total" int


linksDecoder : Decoder PaginationLinks
linksDecoder =
Expand Down
6 changes: 2 additions & 4 deletions ruby_event_store-browser/elm/src/Flags.elm
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ type alias RawFlags =
{ rootUrl : String
, apiUrl : String
, resVersion : String
, repositoryAdapter : String
, platform : String
}

Expand All @@ -16,11 +15,10 @@ type alias Flags =
{ rootUrl : Url.Url
, apiUrl : Url.Url
, resVersion : String
, repositoryAdapter : String
, platform : String
}


buildFlags : RawFlags -> Maybe Flags
buildFlags { rootUrl, apiUrl, resVersion, repositoryAdapter, platform } =
Maybe.map5 Flags (Url.fromString rootUrl) (Url.fromString apiUrl) (Just resVersion) (Just repositoryAdapter) (Just platform)
buildFlags { rootUrl, apiUrl, resVersion, platform } =
Maybe.map4 Flags (Url.fromString rootUrl) (Url.fromString apiUrl) (Just resVersion) (Just platform)
Loading