From 202b9d3e766f0afbb9b68582147222ebe59c4859 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Reszke?= Date: Thu, 25 Jul 2024 08:35:52 +0200 Subject: [PATCH 01/42] Revert "Do not assert specific adapter being used" This reverts commit fe9b7e4f027f47e83a1cf3527f3358045ae80f8d. --- ruby_event_store-active_record/spec/event_repository_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ruby_event_store-active_record/spec/event_repository_spec.rb b/ruby_event_store-active_record/spec/event_repository_spec.rb index 1e87c14917..65865f1a5a 100644 --- a/ruby_event_store-active_record/spec/event_repository_spec.rb +++ b/ruby_event_store-active_record/spec/event_repository_spec.rb @@ -380,7 +380,7 @@ module ActiveRecord describe "#inspect" do specify "returns string representation" do - expect(repository.inspect).to eq("RubyEventStore::ActiveRecord::EventRepository with #{::ActiveRecord::Base.connection.adapter_name} db adapter") + expect(repository.inspect).to eq("RubyEventStore::ActiveRecord::EventRepository with SQLite db adapter") end end From 1ae2c928d02b26a2ee8fb620a5b81d27b677b4d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Reszke?= Date: Thu, 25 Jul 2024 08:35:56 +0200 Subject: [PATCH 02/42] Revert "specification -> inspect, repository_specification -> inspect_repository" This reverts commit 33c90647d54abf7b66f61c74103e6544f3c6157c. --- .../active_record/event_repository.rb | 4 +-- .../spec/event_repository_spec.rb | 6 ---- .../lib/ruby_event_store/browser/app.rb | 2 +- .../lib/ruby_event_store/client.rb | 8 +++--- .../instrumented_repository.rb | 13 +++++---- ruby_event_store/spec/client_spec.rb | 16 ----------- .../spec/instrumented_repository_spec.rb | 28 ++++++------------- 7 files changed, 22 insertions(+), 55 deletions(-) diff --git a/ruby_event_store-active_record/lib/ruby_event_store/active_record/event_repository.rb b/ruby_event_store-active_record/lib/ruby_event_store/active_record/event_repository.rb index c7e4712e7c..4ef9a72b35 100644 --- a/ruby_event_store-active_record/lib/ruby_event_store/active_record/event_repository.rb +++ b/ruby_event_store-active_record/lib/ruby_event_store/active_record/event_repository.rb @@ -85,8 +85,8 @@ 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" + def specification + "#{self.class.name} with #{::ActiveRecord::Base.connection.adapter_name} db adapter" end private diff --git a/ruby_event_store-active_record/spec/event_repository_spec.rb b/ruby_event_store-active_record/spec/event_repository_spec.rb index 65865f1a5a..0d188f18f3 100644 --- a/ruby_event_store-active_record/spec/event_repository_spec.rb +++ b/ruby_event_store-active_record/spec/event_repository_spec.rb @@ -378,12 +378,6 @@ module ActiveRecord }x end - describe "#inspect" do - specify "returns string representation" do - expect(repository.inspect).to eq("RubyEventStore::ActiveRecord::EventRepository with SQLite db adapter") - end - end - private def with_precision(time) diff --git a/ruby_event_store-browser/lib/ruby_event_store/browser/app.rb b/ruby_event_store-browser/lib/ruby_event_store/browser/app.rb index b8b2e08fe1..022c8515be 100644 --- a/ruby_event_store-browser/lib/ruby_event_store/browser/app.rb +++ b/ruby_event_store-browser/lib/ruby_event_store/browser/app.rb @@ -172,7 +172,7 @@ def res_version end def repository_adapter - event_store.inspect_repository + event_store.repository_specification end end end diff --git a/ruby_event_store/lib/ruby_event_store/client.rb b/ruby_event_store/lib/ruby_event_store/client.rb index 2aa77f3ec1..98fc07e212 100644 --- a/ruby_event_store/lib/ruby_event_store/client.rb +++ b/ruby_event_store/lib/ruby_event_store/client.rb @@ -337,11 +337,11 @@ def inspect "#<#{self.class}:0x#{__id__.to_s(16)}>" end - def inspect_repository - if repository.public_method(:inspect).owner.equal?(Kernel) - repository.class.inspect + def repository_specification + if repository.respond_to?(:specification) + repository.specification else - repository.inspect + repository.class.to_s end end diff --git a/ruby_event_store/lib/ruby_event_store/instrumented_repository.rb b/ruby_event_store/lib/ruby_event_store/instrumented_repository.rb index b0a635974b..a5049e5e2d 100644 --- a/ruby_event_store/lib/ruby_event_store/instrumented_repository.rb +++ b/ruby_event_store/lib/ruby_event_store/instrumented_repository.rb @@ -61,12 +61,13 @@ def respond_to_missing?(method_name, _include_private) repository.respond_to?(method_name) end - def inspect - "Instrumented " + if repository.public_method(:inspect).owner.equal?(Kernel) - repository.class.inspect - else - repository.inspect - end + def specification + "Instrumented " + + if repository.respond_to?(:specification) + repository.specification + else + repository.class.to_s + end end private diff --git a/ruby_event_store/spec/client_spec.rb b/ruby_event_store/spec/client_spec.rb index 5ce529ef9a..996d937122 100644 --- a/ruby_event_store/spec/client_spec.rb +++ b/ruby_event_store/spec/client_spec.rb @@ -1001,21 +1001,5 @@ def event_id expect(client.event_in_stream?(fact.event_id, GLOBAL_STREAM)).to eq(true) expect(client.event_in_stream?("924acfb8-755d-4fd5-b758-f92423b6560a", GLOBAL_STREAM)).to eq(false) end - - describe "#inspect_repository" do - specify "repository class name is returned unless inspect is overridden" do - expect(client.inspect_repository).to eq("RubyEventStore::InMemoryRepository") - end - - specify "repository custom inspection string returned if defined" do - class CustomRepository - def inspect - "CustomInspectionString" - end - end - client = Client.new(repository: CustomRepository.new) - expect(client.inspect_repository).to eq("CustomInspectionString") - end - end end end diff --git a/ruby_event_store/spec/instrumented_repository_spec.rb b/ruby_event_store/spec/instrumented_repository_spec.rb index 8096cf1995..4243855a7d 100644 --- a/ruby_event_store/spec/instrumented_repository_spec.rb +++ b/ruby_event_store/spec/instrumented_repository_spec.rb @@ -171,23 +171,11 @@ module RubyEventStore end end - describe "inspect" do - it "'Instrumented ' + repository class name is returned unless inspect is overridden" do - SomeRepository = Class.new - instrumented_repository = InstrumentedRepository.new(SomeRepository.new, ActiveSupport::Notifications) - expect(instrumented_repository.inspect).to eq("Instrumented RubyEventStore::SomeRepository") - end - - specify "'Instrumented ' + repository custom inspection string returned if defined" do - class CustomRepository - def inspect - "CustomInspectionString" - end - end - - instrumented_repository = InstrumentedRepository.new(CustomRepository.new, ActiveSupport::Notifications) - client = Client.new(repository: instrumented_repository) - expect(client.inspect_repository).to eq("Instrumented CustomInspectionString") + describe "specification" do + it "present which repository is instrumented" do + some_repository = double("Some repository") + instrumented_repository = InstrumentedRepository.new(some_repository, ActiveSupport::Notifications) + expect(instrumented_repository.specification).to eq("Instrumented RSpec::Mocks::Double") end end @@ -209,9 +197,9 @@ def inspect expect(instrumented_repository).not_to respond_to(:arbitrary_method_name) expect { instrumented_repository.arbitrary_method_name }.to raise_error( - NoMethodError, - /undefined method `arbitrary_method_name' for .+RubyEventStore::InstrumentedRepository/ - ) + NoMethodError, + /undefined method `arbitrary_method_name' for .+RubyEventStore::InstrumentedRepository/ + ) end def subscribe_to(name) From 64c4ed6ae816567d94f0c2f7c2a762fb4449eb26 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Reszke?= Date: Thu, 25 Jul 2024 08:39:10 +0200 Subject: [PATCH 03/42] Revert "One more formatter round" This reverts commit 974d1b66612ff6992304be8e815f62f19d748f96. --- ruby_event_store-browser/elm/src/Api.elm | 17 ++++------------- ruby_event_store-browser/elm/src/Main.elm | 20 +++++++++----------- 2 files changed, 13 insertions(+), 24 deletions(-) diff --git a/ruby_event_store-browser/elm/src/Api.elm b/ruby_event_store-browser/elm/src/Api.elm index 5588e6cde4..4296e7db1c 100644 --- a/ruby_event_store-browser/elm/src/Api.elm +++ b/ruby_event_store-browser/elm/src/Api.elm @@ -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(..), SearchStream, Stream, emptyPaginatedList, eventDecoder, eventsDecoder, getEvent, getEvents, getSearchStreams, getStream, searchStreamsDecoder, Stats, getStats) 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, int) import Json.Decode.Pipeline exposing (optional, optionalAt, required, requiredAt) import Json.Encode exposing (encode) import Maybe.Extra @@ -42,12 +42,10 @@ type alias SearchStream = { streamId : String } - type alias Stats = - { eventsInTotal : Int + { eventsInTotal: Int } - type alias PaginatedList a = { pagination : Pagination.Specification , events : List a @@ -98,12 +96,10 @@ 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 = Http.get @@ -127,15 +123,13 @@ getSearchStreams msgBuilder flags query = , expect = Http.expectJson msgBuilder searchStreamsDecoder } - -getStats : (Result Http.Error Stats -> msg) -> Flags -> Cmd msg +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 = eventDecoder_ @@ -201,19 +195,16 @@ 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 = succeed PaginationLinks diff --git a/ruby_event_store-browser/elm/src/Main.elm b/ruby_event_store-browser/elm/src/Main.elm index c610bf064a..979c5fa74e 100644 --- a/ruby_event_store-browser/elm/src/Main.elm +++ b/ruby_event_store-browser/elm/src/Main.elm @@ -11,6 +11,7 @@ import LinkedTimezones exposing (mapLinkedTimeZone) import Page.Debug import Page.ShowEvent import Page.ShowStream +import Page.Debug import Route import Task import Time @@ -52,7 +53,6 @@ type Msg | ReceiveTimeZone (Result String Time.ZoneName) | GotDebugMsg Page.Debug.Msg - type Page = NotFound | ShowEvent Page.ShowEvent.Model @@ -133,12 +133,13 @@ update msg model = ( GotDebugMsg gotDebugMsg, Debug debugModel ) -> let - ( subModel, subCmd ) = + (subModel, subCmd) = Page.Debug.update gotDebugMsg debugModel in - ( { model | page = Debug subModel } - , Cmd.map GotDebugMsg subCmd - ) + ({model | page = Debug subModel} + , Cmd.map GotDebugMsg subCmd + ) + ( GotLayoutMsg layoutMsg, _ ) -> case model.flags of @@ -224,13 +225,10 @@ navigate model location = Nothing -> ( { model | page = NotFound }, Cmd.none ) - Just Route.Debug -> + Just (Route.Debug) -> let - page = - Page.Debug.init flags - - cmd = - Page.Debug.initCmd flags + page = Page.Debug.init flags + cmd = Page.Debug.initCmd flags in ( { model | page = Debug page }, Cmd.map GotDebugMsg cmd ) From 2811536f85f51ad33580326a7de0d5c8b1e97b57 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Reszke?= Date: Thu, 25 Jul 2024 08:39:30 +0200 Subject: [PATCH 04/42] Revert "formatting" This reverts commit df409f4dabcf6b09e8fd5e5a05096609756cde92. --- .../elm/src/Page/Debug.elm | 46 ++++++++----------- 1 file changed, 19 insertions(+), 27 deletions(-) diff --git a/ruby_event_store-browser/elm/src/Page/Debug.elm b/ruby_event_store-browser/elm/src/Page/Debug.elm index 63d9c47489..db3fa8d655 100644 --- a/ruby_event_store-browser/elm/src/Page/Debug.elm +++ b/ruby_event_store-browser/elm/src/Page/Debug.elm @@ -1,45 +1,37 @@ module Page.Debug exposing (..) -import Api exposing (Stats, getStats) -import Flags exposing (Flags) import Html exposing (..) +import Flags exposing (Flags) +import Api exposing (getStats, Stats) import Http - -type alias Model = - { resVersion : String, repositoryAdapter : String, eventsInTotal : String } - +type alias Model = { resVersion : String, repositoryAdapter : String, eventsInTotal : String } type Msg - = GotStats (Result Http.Error Stats) - + = GotStats (Result Http.Error Stats) init : Flags -> Model -init flags = +init flags = { resVersion = flags.resVersion, repositoryAdapter = flags.repositoryAdapter, eventsInTotal = "" } - initCmd : Flags -> Cmd Msg initCmd flags = getStats GotStats flags - -view : Model -> Html a +view: Model -> Html a view model = - div [] - [ p [] [ text ("RubyEventStore version: " ++ model.resVersion) ] - , p [] [ text ("RubyEventStore adapter: " ++ model.repositoryAdapter) ] - , p [] [ text ("Events in total: " ++ model.eventsInTotal) ] - ] + div [] [ + p [] [text ("RubyEventStore version: " ++ model.resVersion)], + p [] [text ("RubyEventStore adapter: " ++ model.repositoryAdapter)], + p [] [text ("Events in total: " ++ model.eventsInTotal)] + ] - -update : Msg -> Model -> ( Model, Cmd Msg ) +update : Msg -> Model -> (Model, Cmd Msg) update msg model = - case msg of - GotStats result -> - case result of - Ok stats -> - ( { model | eventsInTotal = String.fromInt stats.eventsInTotal }, Cmd.none ) - - Err _ -> - ( model, Cmd.none ) + case msg of + GotStats result -> + case result of + Ok stats -> + ({ model | eventsInTotal = String.fromInt stats.eventsInTotal }, Cmd.none) + Err _ -> + (model, Cmd.none) \ No newline at end of file From bfd0bd099112a9f036eacabbe99eba2fe004f3ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Reszke?= Date: Thu, 25 Jul 2024 08:39:36 +0200 Subject: [PATCH 05/42] Revert "Add total events counter to the debug page" This reverts commit 4376e1fc098784457d43582d60e7c81b3a274f87. --- ruby_event_store-browser/elm/src/Api.elm | 25 +----------- ruby_event_store-browser/elm/src/Main.elm | 21 ++-------- .../elm/src/Page/Debug.elm | 38 ++++++------------- .../lib/ruby_event_store/browser.rb | 1 - .../lib/ruby_event_store/browser/app.rb | 6 +-- .../lib/ruby_event_store/browser/get_stats.rb | 27 ------------- .../spec/api/stats_spec.rb | 16 -------- 7 files changed, 17 insertions(+), 117 deletions(-) delete mode 100644 ruby_event_store-browser/lib/ruby_event_store/browser/get_stats.rb delete mode 100644 ruby_event_store-browser/spec/api/stats_spec.rb diff --git a/ruby_event_store-browser/elm/src/Api.elm b/ruby_event_store-browser/elm/src/Api.elm index 4296e7db1c..6ed645f59a 100644 --- a/ruby_event_store-browser/elm/src/Api.elm +++ b/ruby_event_store-browser/elm/src/Api.elm @@ -1,9 +1,9 @@ -module Api exposing (Event, PaginatedList, PaginationLink, PaginationLinks, RemoteResource(..), SearchStream, Stream, emptyPaginatedList, eventDecoder, eventsDecoder, getEvent, getEvents, getSearchStreams, getStream, searchStreamsDecoder, Stats, getStats) +module Api exposing (Event, PaginatedList, PaginationLink, PaginationLinks, RemoteResource(..), SearchStream, Stream, emptyPaginatedList, eventDecoder, eventsDecoder, getEvent, getEvents, getSearchStreams, getStream, searchStreamsDecoder) import Flags exposing (Flags) import Http import Iso8601 -import Json.Decode exposing (Decoder, field, list, maybe, string, succeed, value, int) +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 @@ -42,9 +42,6 @@ type alias SearchStream = { streamId : String } -type alias Stats = - { eventsInTotal: Int - } type alias PaginatedList a = { pagination : Pagination.Specification @@ -96,9 +93,6 @@ 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 = @@ -123,12 +117,6 @@ getSearchStreams msgBuilder 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 = @@ -195,15 +183,6 @@ 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 = diff --git a/ruby_event_store-browser/elm/src/Main.elm b/ruby_event_store-browser/elm/src/Main.elm index 979c5fa74e..0bb2dec205 100644 --- a/ruby_event_store-browser/elm/src/Main.elm +++ b/ruby_event_store-browser/elm/src/Main.elm @@ -11,7 +11,6 @@ import LinkedTimezones exposing (mapLinkedTimeZone) import Page.Debug import Page.ShowEvent import Page.ShowStream -import Page.Debug import Route import Task import Time @@ -51,7 +50,7 @@ type Msg | GotShowEventMsg Page.ShowEvent.Msg | GotShowStreamMsg Page.ShowStream.Msg | ReceiveTimeZone (Result String Time.ZoneName) - | GotDebugMsg Page.Debug.Msg + type Page = NotFound @@ -131,16 +130,6 @@ update msg model = , Cmd.map GotShowEventMsg subCmd ) - ( GotDebugMsg gotDebugMsg, Debug debugModel ) -> - let - (subModel, subCmd) = - Page.Debug.update gotDebugMsg debugModel - in - ({model | page = Debug subModel} - , Cmd.map GotDebugMsg subCmd - ) - - ( GotLayoutMsg layoutMsg, _ ) -> case model.flags of Nothing -> @@ -225,12 +214,8 @@ navigate model location = Nothing -> ( { model | page = NotFound }, Cmd.none ) - Just (Route.Debug) -> - let - page = Page.Debug.init flags - cmd = Page.Debug.initCmd flags - in - ( { model | page = Debug page }, Cmd.map GotDebugMsg cmd ) + Just Route.Debug -> + ( { model | page = Debug (Page.Debug.init flags) }, Cmd.none ) Nothing -> ( { model | page = NotFound }, Cmd.none ) diff --git a/ruby_event_store-browser/elm/src/Page/Debug.elm b/ruby_event_store-browser/elm/src/Page/Debug.elm index db3fa8d655..c5cf926cdc 100644 --- a/ruby_event_store-browser/elm/src/Page/Debug.elm +++ b/ruby_event_store-browser/elm/src/Page/Debug.elm @@ -1,37 +1,21 @@ module Page.Debug exposing (..) -import Html exposing (..) import Flags exposing (Flags) -import Api exposing (getStats, Stats) -import Http +import Html exposing (..) -type alias Model = { resVersion : String, repositoryAdapter : String, eventsInTotal : String } -type Msg - = GotStats (Result Http.Error Stats) +type alias Model = + { resVersion : String, repositoryAdapter : String } + init : Flags -> Model -init flags = - { resVersion = flags.resVersion, repositoryAdapter = flags.repositoryAdapter, eventsInTotal = "" } +init flags = + { resVersion = flags.resVersion, repositoryAdapter = flags.repositoryAdapter } -initCmd : Flags -> Cmd Msg -initCmd flags = - getStats GotStats flags -view: Model -> Html a +view : Model -> Html a view model = - div [] [ - p [] [text ("RubyEventStore version: " ++ model.resVersion)], - p [] [text ("RubyEventStore adapter: " ++ model.repositoryAdapter)], - p [] [text ("Events in total: " ++ model.eventsInTotal)] - ] - -update : Msg -> Model -> (Model, Cmd Msg) -update msg model = - case msg of - GotStats result -> - case result of - Ok stats -> - ({ model | eventsInTotal = String.fromInt stats.eventsInTotal }, Cmd.none) - Err _ -> - (model, Cmd.none) \ No newline at end of file + div [] + [ p [] [ text ("RubyEventStore version: " ++ model.resVersion) ] + , p [] [ text ("RubyEventStore adapter: " ++ model.repositoryAdapter) ] + ] diff --git a/ruby_event_store-browser/lib/ruby_event_store/browser.rb b/ruby_event_store-browser/lib/ruby_event_store/browser.rb index 586eafe817..8b73ff80d2 100644 --- a/ruby_event_store-browser/lib/ruby_event_store/browser.rb +++ b/ruby_event_store-browser/lib/ruby_event_store/browser.rb @@ -17,4 +17,3 @@ module Browser require_relative "browser/urls" require_relative "browser/gem_source" require_relative "browser/router" -require_relative "browser/get_stats" \ No newline at end of file diff --git a/ruby_event_store-browser/lib/ruby_event_store/browser/app.rb b/ruby_event_store-browser/lib/ruby_event_store/browser/app.rb index 022c8515be..af6d495578 100644 --- a/ruby_event_store-browser/lib/ruby_event_store/browser/app.rb +++ b/ruby_event_store-browser/lib/ruby_event_store/browser/app.rb @@ -100,11 +100,7 @@ def call(env) stream_name: params.fetch("stream_name"), ) end - router.add_route("GET", "/api/stats") do - json GetStats.new( - event_store: event_store - ) - end + %w[/ /events/:event_id /streams/:stream_name /debug].each do |starting_route| router.add_route("GET", starting_route) do |_, urls| erb bootstrap_html, diff --git a/ruby_event_store-browser/lib/ruby_event_store/browser/get_stats.rb b/ruby_event_store-browser/lib/ruby_event_store/browser/get_stats.rb deleted file mode 100644 index 9048eda6f4..0000000000 --- a/ruby_event_store-browser/lib/ruby_event_store/browser/get_stats.rb +++ /dev/null @@ -1,27 +0,0 @@ -# frozen_string_literal: true - -module RubyEventStore - module Browser - class GetStats - def initialize(event_store:) - @event_store = event_store - end - - def to_h - { - meta: { - events_in_total: events - } - } - end - - private - - def events - event_store.read.count - end - - attr_reader :event_store - end - end -end diff --git a/ruby_event_store-browser/spec/api/stats_spec.rb b/ruby_event_store-browser/spec/api/stats_spec.rb deleted file mode 100644 index 881a228a5e..0000000000 --- a/ruby_event_store-browser/spec/api/stats_spec.rb +++ /dev/null @@ -1,16 +0,0 @@ -# frozen_string_literal: true - -require "spec_helper" - -module RubyEventStore - ::RSpec.describe Browser do - include Browser::IntegrationHelpers - - specify "not existing" do - api_client.get "/api/stats" - expect(api_client.parsed_body["meta"]).to match({ - "events_in_total" => 0 - }) - end - end -end From 09f1a55981a6ecd366ef880cda8a2676a8cbb4e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Reszke?= Date: Thu, 25 Jul 2024 08:39:40 +0200 Subject: [PATCH 06/42] Revert "Format Page.Debug" This reverts commit e0b6a24c013cb0a4d8732e3419c5b75ac2655cac. --- .../elm/src/Page/Debug.elm | 22 ++++++++----------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/ruby_event_store-browser/elm/src/Page/Debug.elm b/ruby_event_store-browser/elm/src/Page/Debug.elm index c5cf926cdc..016d8e4926 100644 --- a/ruby_event_store-browser/elm/src/Page/Debug.elm +++ b/ruby_event_store-browser/elm/src/Page/Debug.elm @@ -1,21 +1,17 @@ module Page.Debug exposing (..) -import Flags exposing (Flags) import Html exposing (..) +import Flags exposing (Flags) - -type alias Model = - { resVersion : String, repositoryAdapter : String } - +type alias Model = { resVersion : String, repositoryAdapter : String } init : Flags -> Model -init flags = - { resVersion = flags.resVersion, repositoryAdapter = flags.repositoryAdapter } - +init flags = + { resVersion = flags.resVersion, repositoryAdapter = flags.repositoryAdapter } -view : Model -> Html a +view: Model -> Html a view model = - div [] - [ p [] [ text ("RubyEventStore version: " ++ model.resVersion) ] - , p [] [ text ("RubyEventStore adapter: " ++ model.repositoryAdapter) ] - ] + div [] [ + p [] [text ("RubyEventStore version: " ++ model.resVersion)], + p [] [text ("RubyEventStore adapter: " ++ model.repositoryAdapter)] + ] From bd9d19e7dbaa1ac98d2a15af730bd63190925334 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Reszke?= Date: Thu, 25 Jul 2024 08:39:45 +0200 Subject: [PATCH 07/42] Revert "Format Main" This reverts commit 124b235305a5397d0f46b0d94fd6dd73439fb2e0. --- ruby_event_store-browser/elm/src/Main.elm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ruby_event_store-browser/elm/src/Main.elm b/ruby_event_store-browser/elm/src/Main.elm index 0bb2dec205..c379067ae8 100644 --- a/ruby_event_store-browser/elm/src/Main.elm +++ b/ruby_event_store-browser/elm/src/Main.elm @@ -8,9 +8,9 @@ import Flags exposing (Flags, RawFlags, buildFlags) import Html exposing (..) import Layout import LinkedTimezones exposing (mapLinkedTimeZone) -import Page.Debug import Page.ShowEvent import Page.ShowStream +import Page.Debug import Route import Task import Time @@ -214,7 +214,7 @@ navigate model location = Nothing -> ( { model | page = NotFound }, Cmd.none ) - Just Route.Debug -> + Just (Route.Debug) -> ( { model | page = Debug (Page.Debug.init flags) }, Cmd.none ) Nothing -> From 3715b433ce11532c2fa32f40230df556200bb70a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Reszke?= Date: Thu, 25 Jul 2024 08:39:49 +0200 Subject: [PATCH 08/42] Revert "Format Route" This reverts commit 8459e55ce34df26d67d7d8123309a2b63648f9b3. --- ruby_event_store-browser/elm/src/Route.elm | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/ruby_event_store-browser/elm/src/Route.elm b/ruby_event_store-browser/elm/src/Route.elm index 28a9085abb..d867de1956 100644 --- a/ruby_event_store-browser/elm/src/Route.elm +++ b/ruby_event_store-browser/elm/src/Route.elm @@ -1,4 +1,4 @@ -module Route exposing (Route(..), buildUrl, debugUrl, decodeLocation, eventUrl, paginatedStreamUrl, streamUrl) +module Route exposing (Route(..), buildUrl, decodeLocation, eventUrl, paginatedStreamUrl, streamUrl, debugUrl) import Maybe.Extra import Pagination @@ -54,12 +54,10 @@ eventUrl : Url.Url -> String -> String eventUrl baseUrl eventId = buildUrl baseUrl [ "events", Url.percentEncode eventId ] [] - debugUrl : Url.Url -> String debugUrl baseUrl = buildUrl baseUrl [ "debug" ] [] - pathSegments : Url.Url -> List String pathSegments baseUrl = List.filter (\e -> e /= "") (String.split "/" baseUrl.path) From dd443df9c37b08de3fd75139657334a8ec5e4bde Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Reszke?= Date: Thu, 25 Jul 2024 08:40:03 +0200 Subject: [PATCH 09/42] Revert "add order to rom" This reverts commit 3ab31cf4fe083944217b2c49e095d4cb35a482c3. --- .../lib/ruby_event_store/rom/repositories/stream_entries.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/contrib/ruby_event_store-rom/lib/ruby_event_store/rom/repositories/stream_entries.rb b/contrib/ruby_event_store-rom/lib/ruby_event_store/rom/repositories/stream_entries.rb index fb507206b0..b9f8ba1b6f 100644 --- a/contrib/ruby_event_store-rom/lib/ruby_event_store/rom/repositories/stream_entries.rb +++ b/contrib/ruby_event_store-rom/lib/ruby_event_store/rom/repositories/stream_entries.rb @@ -52,7 +52,6 @@ def search_streams(stream_name) .where { stream.like("#{stream_name}%") } .distinct .limit(10) - .order(:stream) .pluck(:stream) .map { |name| Stream.new(name) } end From 3040d946c060306eb8163fad6992215f07e12fb5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Reszke?= Date: Thu, 25 Jul 2024 08:40:22 +0200 Subject: [PATCH 10/42] Revert "Search streams for sequel" This reverts commit 0f0b8a04c91e17df96ebaf9be849a86387b1ce47. --- .../lib/ruby_event_store/sequel/event_repository.rb | 8 -------- 1 file changed, 8 deletions(-) diff --git a/contrib/ruby_event_store-sequel/lib/ruby_event_store/sequel/event_repository.rb b/contrib/ruby_event_store-sequel/lib/ruby_event_store/sequel/event_repository.rb index e7732d1d53..2bb0571a7e 100644 --- a/contrib/ruby_event_store-sequel/lib/ruby_event_store/sequel/event_repository.rb +++ b/contrib/ruby_event_store-sequel/lib/ruby_event_store/sequel/event_repository.rb @@ -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) From d31e737932119426bd42f087099801c605d0819b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Reszke?= Date: Thu, 25 Jul 2024 08:40:29 +0200 Subject: [PATCH 11/42] Revert "Implement search_streams in ROM" This reverts commit daad41762ddc2bda94dd78cb9744863b07da160d. --- .../lib/ruby_event_store/rom/event_repository.rb | 4 ---- .../ruby_event_store/rom/repositories/stream_entries.rb | 9 --------- 2 files changed, 13 deletions(-) diff --git a/contrib/ruby_event_store-rom/lib/ruby_event_store/rom/event_repository.rb b/contrib/ruby_event_store-rom/lib/ruby_event_store/rom/event_repository.rb index dc25c9d24f..a25b7055f6 100644 --- a/contrib/ruby_event_store-rom/lib/ruby_event_store/rom/event_repository.rb +++ b/contrib/ruby_event_store-rom/lib/ruby_event_store/rom/event_repository.rb @@ -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) diff --git a/contrib/ruby_event_store-rom/lib/ruby_event_store/rom/repositories/stream_entries.rb b/contrib/ruby_event_store-rom/lib/ruby_event_store/rom/repositories/stream_entries.rb index b9f8ba1b6f..df662482e8 100644 --- a/contrib/ruby_event_store-rom/lib/ruby_event_store/rom/repositories/stream_entries.rb +++ b/contrib/ruby_event_store-rom/lib/ruby_event_store/rom/repositories/stream_entries.rb @@ -46,15 +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) - .pluck(:stream) - .map { |name| Stream.new(name) } - end end end end From 1a69872f45bec2ad8178287a7666907eec96cd44 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Reszke?= Date: Thu, 25 Jul 2024 08:42:13 +0200 Subject: [PATCH 12/42] Revert "Add debug url to the browser layout" This reverts commit c42c546ab6ef2ae6f616e97fa8f23d7e6023becb. --- ruby_event_store-browser/elm/src/Layout.elm | 2 -- ruby_event_store-browser/elm/src/Route.elm | 5 +---- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/ruby_event_store-browser/elm/src/Layout.elm b/ruby_event_store-browser/elm/src/Layout.elm index 543f7c8ce4..f3ca796810 100644 --- a/ruby_event_store-browser/elm/src/Layout.elm +++ b/ruby_event_store-browser/elm/src/Layout.elm @@ -258,8 +258,6 @@ browserFooter { flags, time } = , link "Documentation" "https://railseventstore.org/docs/install/" , spacer , link "Support" "https://railseventstore.org/support/" - , spacer - , link "Debug" (Route.debugUrl flags.rootUrl) ] , div [ class "text-gray-500 text-sm flex item-center gap-2" ] diff --git a/ruby_event_store-browser/elm/src/Route.elm b/ruby_event_store-browser/elm/src/Route.elm index d867de1956..6aa7599145 100644 --- a/ruby_event_store-browser/elm/src/Route.elm +++ b/ruby_event_store-browser/elm/src/Route.elm @@ -1,4 +1,4 @@ -module Route exposing (Route(..), buildUrl, decodeLocation, eventUrl, paginatedStreamUrl, streamUrl, debugUrl) +module Route exposing (Route(..), buildUrl, decodeLocation, eventUrl, paginatedStreamUrl, streamUrl) import Maybe.Extra import Pagination @@ -54,9 +54,6 @@ eventUrl : Url.Url -> String -> String eventUrl baseUrl eventId = buildUrl baseUrl [ "events", Url.percentEncode eventId ] [] -debugUrl : Url.Url -> String -debugUrl baseUrl = - buildUrl baseUrl [ "debug" ] [] pathSegments : Url.Url -> List String pathSegments baseUrl = From 02dcfb5daacc05d8a2214ae704010887a6957bf5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Reszke?= Date: Thu, 25 Jul 2024 08:42:45 +0200 Subject: [PATCH 13/42] Revert "Adjust test" This reverts commit 35d33de20f97fb3a795dc213a63393b965b3a52f. --- ruby_event_store/spec/client_spec.rb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/ruby_event_store/spec/client_spec.rb b/ruby_event_store/spec/client_spec.rb index 996d937122..c9661827e0 100644 --- a/ruby_event_store/spec/client_spec.rb +++ b/ruby_event_store/spec/client_spec.rb @@ -852,11 +852,11 @@ module RubyEventStore client.append(event_2, stream_name: stream_2.name) client.append(event_3, stream_name: stream_3.name) - expect(client.search_streams("str")).to match_array [stream_3, stream_2, stream_1] - expect(client.search_streams("stream-1")).to match_array [stream_1] - expect(client.search_streams("stream-2")).to match_array [stream_2] - expect(client.search_streams("stream-3")).to match_array [stream_3] - expect(client.search_streams("stream-4")).to match_array [] + expect(client.search_streams("str")).to eq [stream_3, stream_2, stream_1] + expect(client.search_streams("stream-1")).to eq [stream_1] + expect(client.search_streams("stream-2")).to eq [stream_2] + expect(client.search_streams("stream-3")).to eq [stream_3] + expect(client.search_streams("stream-4")).to eq [] end describe "#subscribers_for" do From d14ba04b7357022d97000df089a59ac897b5cf4d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Reszke?= Date: Thu, 25 Jul 2024 08:42:53 +0200 Subject: [PATCH 14/42] Revert "We don't mind the order" This reverts commit 0f3f4ffe39092d5404e5eb95503c5a31f9fe0763. --- ruby_event_store/lib/ruby_event_store/in_memory_repository.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/ruby_event_store/lib/ruby_event_store/in_memory_repository.rb b/ruby_event_store/lib/ruby_event_store/in_memory_repository.rb index abb25aca8f..7f96811c72 100644 --- a/ruby_event_store/lib/ruby_event_store/in_memory_repository.rb +++ b/ruby_event_store/lib/ruby_event_store/in_memory_repository.rb @@ -130,6 +130,7 @@ def search_streams(stream_name) streams .select { |name,| name.include?(stream_name) } .take(10) + .reverse .map { |name,| Stream.new(name) } end From 04a846928d12e3dbb074c05508c7241eb2f0d48a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Reszke?= Date: Thu, 25 Jul 2024 08:43:06 +0200 Subject: [PATCH 15/42] Revert "adjust tests" This reverts commit f1726beae17be5b1027e56cc4fa4d90473387761. --- .../spec/event_repository_spec.rb | 10 +++++++--- .../spec/api/search_streams_spec.rb | 1 + .../lib/ruby_event_store/in_memory_repository.rb | 2 +- .../ruby_event_store/spec/event_repository_lint.rb | 11 ++++++----- ruby_event_store/spec/client_spec.rb | 2 ++ 5 files changed, 17 insertions(+), 9 deletions(-) diff --git a/ruby_event_store-active_record/spec/event_repository_spec.rb b/ruby_event_store-active_record/spec/event_repository_spec.rb index 0d188f18f3..59557f75b4 100644 --- a/ruby_event_store-active_record/spec/event_repository_spec.rb +++ b/ruby_event_store-active_record/spec/event_repository_spec.rb @@ -196,12 +196,16 @@ module ActiveRecord ) repository.append_to_stream( [SRecord.new(event_id: e3 = SecureRandom.uuid)], - s3 = Stream.new("Dummy$#{e3}"), + 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) + expect(repository.search_streams("Du")).to eq([s3, s2, s1]) + expect(repository.search_streams("du")).to eq([s3, s2, s1]) + expect(repository.search_streams("dum")).to eq([s3, s2, s1]) + expect(repository.search_streams("dumm")).to eq([s3, s2, s1]) + expect(repository.search_streams("dummy")).to eq([s3, s2, s1]) + expect(repository.search_streams("Dummy")).to eq([s3, s2, s1]) end specify "limits searched streams to 10" do diff --git a/ruby_event_store-browser/spec/api/search_streams_spec.rb b/ruby_event_store-browser/spec/api/search_streams_spec.rb index d05c9f32b3..e82e1503b9 100644 --- a/ruby_event_store-browser/spec/api/search_streams_spec.rb +++ b/ruby_event_store-browser/spec/api/search_streams_spec.rb @@ -13,6 +13,7 @@ module RubyEventStore expect(api_client.last_response).to be_ok expect(api_client.parsed_body["data"]).to match_array( [ + { "id" => "$by_type_DummyEvent", "type" => "streams" }, { "id" => "dummy-2", "type" => "streams" }, { "id" => "dummy-1", "type" => "streams" } ] diff --git a/ruby_event_store/lib/ruby_event_store/in_memory_repository.rb b/ruby_event_store/lib/ruby_event_store/in_memory_repository.rb index 7f96811c72..681c3829f5 100644 --- a/ruby_event_store/lib/ruby_event_store/in_memory_repository.rb +++ b/ruby_event_store/lib/ruby_event_store/in_memory_repository.rb @@ -128,7 +128,7 @@ def streams_of(event_id) def search_streams(stream_name) streams - .select { |name,| name.include?(stream_name) } + .select { |name,| name.downcase.include?(stream_name.downcase) } .take(10) .reverse .map { |name,| Stream.new(name) } diff --git a/ruby_event_store/lib/ruby_event_store/spec/event_repository_lint.rb b/ruby_event_store/lib/ruby_event_store/spec/event_repository_lint.rb index d91ea95d0f..1cd112594b 100644 --- a/ruby_event_store/lib/ruby_event_store/spec/event_repository_lint.rb +++ b/ruby_event_store/lib/ruby_event_store/spec/event_repository_lint.rb @@ -1195,10 +1195,11 @@ def read_events_backward(repository, stream = nil, from: nil, to: nil, count: ni repository.append_to_stream([event_2], stream_b, version_any) repository.append_to_stream([event_3], stream_c, version_any) - expect(repository.search_streams("Str")).to contain_exactly stream_c, stream_b, stream_a - expect(repository.search_streams("Stream A")).to contain_exactly stream_a - expect(repository.search_streams("Stream B")).to contain_exactly stream_b - expect(repository.search_streams("Stream C")).to contain_exactly stream_c + expect(repository.search_streams("str")).to eq [stream_c, stream_b, stream_a] + expect(repository.search_streams("Str")).to eq [stream_c, stream_b, stream_a] + expect(repository.search_streams("Stream A")).to eq [stream_a] + expect(repository.search_streams("Stream B")).to eq [stream_b] + expect(repository.search_streams("Stream C")).to eq [stream_c] end specify do @@ -1207,7 +1208,7 @@ def read_events_backward(repository, stream = nil, from: nil, to: nil, count: ni repository.append_to_stream([ SRecord.new(event_id: SecureRandom.uuid)], stream, version_any) end - expect(repository.search_streams("Stream").size).to eq 10 + expect(repository.search_streams("stream").size).to eq 10 end specify do diff --git a/ruby_event_store/spec/client_spec.rb b/ruby_event_store/spec/client_spec.rb index c9661827e0..637cbb2d61 100644 --- a/ruby_event_store/spec/client_spec.rb +++ b/ruby_event_store/spec/client_spec.rb @@ -853,6 +853,8 @@ module RubyEventStore client.append(event_3, stream_name: stream_3.name) expect(client.search_streams("str")).to eq [stream_3, stream_2, stream_1] + expect(client.search_streams("Str")).to eq [stream_3, stream_2, stream_1] + expect(client.search_streams("sTr")).to eq [stream_3, stream_2, stream_1] expect(client.search_streams("stream-1")).to eq [stream_1] expect(client.search_streams("stream-2")).to eq [stream_2] expect(client.search_streams("stream-3")).to eq [stream_3] From 565405581a0317485bf383ce4d17c9b0641a74e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Reszke?= Date: Thu, 25 Jul 2024 08:43:10 +0200 Subject: [PATCH 16/42] Revert "Optimize querys performance" This reverts commit 1596bf78a631530db4c77e54492ede8f6b88a3eb. --- .../active_record/event_repository_reader.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/ruby_event_store-active_record/lib/ruby_event_store/active_record/event_repository_reader.rb b/ruby_event_store-active_record/lib/ruby_event_store/active_record/event_repository_reader.rb index b6158b6171..85ab0cd0e0 100644 --- a/ruby_event_store-active_record/lib/ruby_event_store/active_record/event_repository_reader.rb +++ b/ruby_event_store-active_record/lib/ruby_event_store/active_record/event_repository_reader.rb @@ -59,9 +59,10 @@ def event_in_stream?(event_id, stream) def search_streams(stream) @stream_klass - .where("stream LIKE ?", "#{stream}%") + .where("lower(stream) LIKE ?", "#{stream.downcase}%") + .order("position DESC, id DESC") .limit(10) - .pluck("distinct stream") + .pluck(:stream) .map { |name| Stream.new(name) } end From 851c723a0f14210acb81691c43a1cbff1b83551d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Reszke?= Date: Thu, 25 Jul 2024 08:43:32 +0200 Subject: [PATCH 17/42] Revert "test if InstrumentedRepository presents which repository is instrumented" This reverts commit 1d0dd28ecdd8dcff5f6980ca2cdb5dfff5db9462. --- ruby_event_store/spec/instrumented_repository_spec.rb | 8 -------- 1 file changed, 8 deletions(-) diff --git a/ruby_event_store/spec/instrumented_repository_spec.rb b/ruby_event_store/spec/instrumented_repository_spec.rb index 4243855a7d..3545d28b23 100644 --- a/ruby_event_store/spec/instrumented_repository_spec.rb +++ b/ruby_event_store/spec/instrumented_repository_spec.rb @@ -171,14 +171,6 @@ module RubyEventStore end end - describe "specification" do - it "present which repository is instrumented" do - some_repository = double("Some repository") - instrumented_repository = InstrumentedRepository.new(some_repository, ActiveSupport::Notifications) - expect(instrumented_repository.specification).to eq("Instrumented RSpec::Mocks::Double") - end - end - specify "method unknown by instrumentation but known by repository" do some_repository = double("Some repository", custom_method: 42) instrumented_repository = InstrumentedRepository.new(some_repository, ActiveSupport::Notifications) From 7cde0ae819b3003bcbd6b84d7b1132d088cb9d2a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Reszke?= Date: Thu, 25 Jul 2024 08:43:36 +0200 Subject: [PATCH 18/42] Revert "present which exactly repository is instrumented" This reverts commit 366e4bd8076ecd8118f3b98af1adec8edee85757. --- .../lib/ruby_event_store/instrumented_repository.rb | 9 --------- 1 file changed, 9 deletions(-) diff --git a/ruby_event_store/lib/ruby_event_store/instrumented_repository.rb b/ruby_event_store/lib/ruby_event_store/instrumented_repository.rb index a5049e5e2d..a70311818c 100644 --- a/ruby_event_store/lib/ruby_event_store/instrumented_repository.rb +++ b/ruby_event_store/lib/ruby_event_store/instrumented_repository.rb @@ -61,15 +61,6 @@ def respond_to_missing?(method_name, _include_private) repository.respond_to?(method_name) end - def specification - "Instrumented " + - if repository.respond_to?(:specification) - repository.specification - else - repository.class.to_s - end - end - private attr_reader :repository, :instrumentation From 6919b6549590820e98f06236f36c0ca959ded7e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Reszke?= Date: Thu, 25 Jul 2024 08:43:43 +0200 Subject: [PATCH 19/42] Revert "prettier" This reverts commit 80b88309631aa1dfa1b132b639c38b16d5bda948. --- .../active_record/event_repository_reader.rb | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/ruby_event_store-active_record/lib/ruby_event_store/active_record/event_repository_reader.rb b/ruby_event_store-active_record/lib/ruby_event_store/active_record/event_repository_reader.rb index 85ab0cd0e0..87eef89b2a 100644 --- a/ruby_event_store-active_record/lib/ruby_event_store/active_record/event_repository_reader.rb +++ b/ruby_event_store-active_record/lib/ruby_event_store/active_record/event_repository_reader.rb @@ -58,12 +58,7 @@ def event_in_stream?(event_id, stream) end def search_streams(stream) - @stream_klass - .where("lower(stream) LIKE ?", "#{stream.downcase}%") - .order("position DESC, id DESC") - .limit(10) - .pluck(:stream) - .map { |name| Stream.new(name) } + @stream_klass.where("lower(stream) LIKE ?", "#{stream.downcase}%").order("position DESC, id DESC").limit(10).pluck(:stream).map { |name| Stream.new(name) } end private From 398c2cd3a30ba698b6616f4a30cca66033084d4a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Reszke?= Date: Thu, 25 Jul 2024 08:43:47 +0200 Subject: [PATCH 20/42] Revert "test if /debug page is served" This reverts commit 39178013124fe0b1fac16eeab27d704e70419ca1. --- ruby_event_store-browser/spec/web_spec.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/ruby_event_store-browser/spec/web_spec.rb b/ruby_event_store-browser/spec/web_spec.rb index 7cca4a5a7f..3acf98ac69 100644 --- a/ruby_event_store-browser/spec/web_spec.rb +++ b/ruby_event_store-browser/spec/web_spec.rb @@ -10,7 +10,6 @@ module RubyEventStore specify { expect(web_client.get("/").content_type).to eq("text/html;charset=utf-8") } specify { expect(web_client.post("/")).to be_not_found } specify { expect(web_client.get("/streams/all")).to be_ok } - specify { expect(web_client.get("/debug")).to be_ok } specify do event_store.append(event = DummyEvent.new) expect(web_client.get("/events/#{event.event_id}")).to be_ok From 3891166ae2ae029ec3230c0e820bde918f8fea07 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Reszke?= Date: Thu, 25 Jul 2024 08:43:51 +0200 Subject: [PATCH 21/42] Revert "test if repositoryAdapter flag is set" This reverts commit 5fba4c8eaa5dd4fb741a8ab9178ca6e2cb90da51. --- ruby_event_store-browser/spec/browser_settings_spec.rb | 6 ------ 1 file changed, 6 deletions(-) diff --git a/ruby_event_store-browser/spec/browser_settings_spec.rb b/ruby_event_store-browser/spec/browser_settings_spec.rb index 39eacad2d7..c929c89940 100644 --- a/ruby_event_store-browser/spec/browser_settings_spec.rb +++ b/ruby_event_store-browser/spec/browser_settings_spec.rb @@ -13,12 +13,6 @@ module RubyEventStore expect(parsed_meta_content(response.body)["resVersion"]).to eq(RubyEventStore::VERSION) end - specify "passes RES repository adapter specification" do - response = web_client.get "/res" - - expect(parsed_meta_content(response.body)["repositoryAdapter"]).to eq('RubyEventStore::InMemoryRepository') - end - specify "passes root_url" do response = web_client.get "/res" From e3db7942252760618894d9ffac9abc53125aeb2f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Reszke?= Date: Thu, 25 Jul 2024 08:43:55 +0200 Subject: [PATCH 22/42] Revert "move `repository_specification` method to the proper class" This reverts commit 947325b3326ff8bc6c12d699d11cab5a72797473. --- ruby_event_store/lib/ruby_event_store/client.rb | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/ruby_event_store/lib/ruby_event_store/client.rb b/ruby_event_store/lib/ruby_event_store/client.rb index 98fc07e212..3326c1c3ff 100644 --- a/ruby_event_store/lib/ruby_event_store/client.rb +++ b/ruby_event_store/lib/ruby_event_store/client.rb @@ -234,6 +234,14 @@ def call unsubs.each(&:call) if unsubs end + def repository_specification + if repository.respond_to?(:specification) + repository.specification + else + repository.class.to_s + end + end + private attr_reader :resolver @@ -337,14 +345,6 @@ def inspect "#<#{self.class}:0x#{__id__.to_s(16)}>" end - def repository_specification - if repository.respond_to?(:specification) - repository.specification - else - repository.class.to_s - end - end - EMPTY_HASH = {}.freeze private_constant :EMPTY_HASH From 58e31c34d11bd9977d3c34eef6e635486d9b4bca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Reszke?= Date: Thu, 25 Jul 2024 09:27:54 +0200 Subject: [PATCH 23/42] Revert "Kill mutants" This reverts commit c7556ea6ba11f338ac248ae2073aeb51198c083f. --- .../lib/ruby_event_store/in_memory_repository.rb | 1 + .../lib/ruby_event_store/spec/event_repository_lint.rb | 9 --------- 2 files changed, 1 insertion(+), 9 deletions(-) diff --git a/ruby_event_store/lib/ruby_event_store/in_memory_repository.rb b/ruby_event_store/lib/ruby_event_store/in_memory_repository.rb index 681c3829f5..45ee6fef75 100644 --- a/ruby_event_store/lib/ruby_event_store/in_memory_repository.rb +++ b/ruby_event_store/lib/ruby_event_store/in_memory_repository.rb @@ -129,6 +129,7 @@ def streams_of(event_id) def search_streams(stream_name) streams .select { |name,| name.downcase.include?(stream_name.downcase) } + .to_a .take(10) .reverse .map { |name,| Stream.new(name) } diff --git a/ruby_event_store/lib/ruby_event_store/spec/event_repository_lint.rb b/ruby_event_store/lib/ruby_event_store/spec/event_repository_lint.rb index 1cd112594b..25e4e5a9ba 100644 --- a/ruby_event_store/lib/ruby_event_store/spec/event_repository_lint.rb +++ b/ruby_event_store/lib/ruby_event_store/spec/event_repository_lint.rb @@ -1202,15 +1202,6 @@ def read_events_backward(repository, stream = nil, from: nil, to: nil, count: ni expect(repository.search_streams("Stream C")).to eq [stream_c] end - specify do - 11.times do |index| - stream = Stream.new("Stream #{index}") - repository.append_to_stream([ SRecord.new(event_id: SecureRandom.uuid)], stream, version_any) - end - - expect(repository.search_streams("stream").size).to eq 10 - end - specify do e1 = SRecord.new(event_id: "8a6f053e-3ce2-4c82-a55b-4d02c66ae6ea") e2 = SRecord.new(event_id: "8cee1139-4f96-483a-a175-2b947283c3c7") From a17731c8ab8dd55c961bc4da94a7874792bf99f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Reszke?= Date: Thu, 25 Jul 2024 09:28:02 +0200 Subject: [PATCH 24/42] Revert "Limit number of searched streams to 10" This reverts commit b41cc6b702cc773b276443712c70375bfa04b434. --- .../active_record/event_repository_reader.rb | 2 +- .../spec/event_repository_spec.rb | 12 ------------ .../spec/api/search_streams_spec.rb | 13 +------------ .../lib/ruby_event_store/in_memory_repository.rb | 1 - 4 files changed, 2 insertions(+), 26 deletions(-) diff --git a/ruby_event_store-active_record/lib/ruby_event_store/active_record/event_repository_reader.rb b/ruby_event_store-active_record/lib/ruby_event_store/active_record/event_repository_reader.rb index 87eef89b2a..8d65059017 100644 --- a/ruby_event_store-active_record/lib/ruby_event_store/active_record/event_repository_reader.rb +++ b/ruby_event_store-active_record/lib/ruby_event_store/active_record/event_repository_reader.rb @@ -58,7 +58,7 @@ def event_in_stream?(event_id, stream) end def search_streams(stream) - @stream_klass.where("lower(stream) LIKE ?", "#{stream.downcase}%").order("position DESC, id DESC").limit(10).pluck(:stream).map { |name| Stream.new(name) } + @stream_klass.where("lower(stream) LIKE ?", "#{stream.downcase}%").order("position DESC, id DESC").pluck(:stream).map { |name| Stream.new(name) } end private diff --git a/ruby_event_store-active_record/spec/event_repository_spec.rb b/ruby_event_store-active_record/spec/event_repository_spec.rb index 59557f75b4..0ce7a87461 100644 --- a/ruby_event_store-active_record/spec/event_repository_spec.rb +++ b/ruby_event_store-active_record/spec/event_repository_spec.rb @@ -208,18 +208,6 @@ module ActiveRecord expect(repository.search_streams("Dummy")).to eq([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)], diff --git a/ruby_event_store-browser/spec/api/search_streams_spec.rb b/ruby_event_store-browser/spec/api/search_streams_spec.rb index e82e1503b9..97a52a5c7c 100644 --- a/ruby_event_store-browser/spec/api/search_streams_spec.rb +++ b/ruby_event_store-browser/spec/api/search_streams_spec.rb @@ -4,7 +4,7 @@ module RubyEventStore ::RSpec.describe Browser do include Browser::IntegrationHelpers - specify "finds desired streams" do + specify "something" do event_store.publish(DummyEvent.new, stream_name: "dummy-1") event_store.publish(DummyEvent.new, stream_name: "dummy-2") @@ -26,16 +26,5 @@ module RubyEventStore [{ "id" => "dummy-2", "type" => "streams" }, { "id" => "dummy-1", "type" => "streams" }] ) end - - specify "limits results to 10" do - 11.times do |index| - event_store.publish(DummyEvent.new, stream_name: "dummy-#{index}") - end - - api_client.get "/api/search_streams/dum" - - expect(api_client.last_response).to be_ok - expect(api_client.parsed_body["data"].size).to eq(10) - end end end diff --git a/ruby_event_store/lib/ruby_event_store/in_memory_repository.rb b/ruby_event_store/lib/ruby_event_store/in_memory_repository.rb index 45ee6fef75..fad6f0a89f 100644 --- a/ruby_event_store/lib/ruby_event_store/in_memory_repository.rb +++ b/ruby_event_store/lib/ruby_event_store/in_memory_repository.rb @@ -130,7 +130,6 @@ def search_streams(stream_name) streams .select { |name,| name.downcase.include?(stream_name.downcase) } .to_a - .take(10) .reverse .map { |name,| Stream.new(name) } end From 04b5a0c298f2d421dad0f21c33d89ea5f0dd1577 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Reszke?= Date: Thu, 25 Jul 2024 09:29:38 +0200 Subject: [PATCH 25/42] Revert "Add repositoryAdapter eml flag" This reverts commit 2d8de23e070eaf5cecb59d28a79a96fbf9f44e2b. --- ruby_event_store-browser/elm/src/Flags.elm | 6 +- ruby_event_store-browser/elm/src/Main.elm | 2 +- .../elm/src/Page/Debug.elm | 14 ++- .../lib/ruby_event_store/browser/app.rb | 85 ++++++++++++------- 4 files changed, 61 insertions(+), 46 deletions(-) diff --git a/ruby_event_store-browser/elm/src/Flags.elm b/ruby_event_store-browser/elm/src/Flags.elm index 372acbe756..d24891ab10 100644 --- a/ruby_event_store-browser/elm/src/Flags.elm +++ b/ruby_event_store-browser/elm/src/Flags.elm @@ -7,7 +7,6 @@ type alias RawFlags = { rootUrl : String , apiUrl : String , resVersion : String - , repositoryAdapter : String , platform : String } @@ -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) diff --git a/ruby_event_store-browser/elm/src/Main.elm b/ruby_event_store-browser/elm/src/Main.elm index c379067ae8..19f4f8ba14 100644 --- a/ruby_event_store-browser/elm/src/Main.elm +++ b/ruby_event_store-browser/elm/src/Main.elm @@ -215,7 +215,7 @@ navigate model location = ( { model | page = NotFound }, Cmd.none ) Just (Route.Debug) -> - ( { model | page = Debug (Page.Debug.init flags) }, Cmd.none ) + ( { model | page = Debug (Page.Debug.init flags.resVersion) }, Cmd.none ) Nothing -> ( { model | page = NotFound }, Cmd.none ) diff --git a/ruby_event_store-browser/elm/src/Page/Debug.elm b/ruby_event_store-browser/elm/src/Page/Debug.elm index 016d8e4926..e75b0c2a85 100644 --- a/ruby_event_store-browser/elm/src/Page/Debug.elm +++ b/ruby_event_store-browser/elm/src/Page/Debug.elm @@ -1,17 +1,13 @@ module Page.Debug exposing (..) import Html exposing (..) -import Flags exposing (Flags) -type alias Model = { resVersion : String, repositoryAdapter : String } +type alias Model = { resVersion : String } -init : Flags -> Model -init flags = - { resVersion = flags.resVersion, repositoryAdapter = flags.repositoryAdapter } +init : String -> Model +init resVersion = + { resVersion = resVersion } view: Model -> Html a view model = - div [] [ - p [] [text ("RubyEventStore version: " ++ model.resVersion)], - p [] [text ("RubyEventStore adapter: " ++ model.repositoryAdapter)] - ] + text ("RubyEventStore version: " ++ model.resVersion) diff --git a/ruby_event_store-browser/lib/ruby_event_store/browser/app.rb b/ruby_event_store-browser/lib/ruby_event_store/browser/app.rb index af6d495578..a27029f48c 100644 --- a/ruby_event_store-browser/lib/ruby_event_store/browser/app.rb +++ b/ruby_event_store-browser/lib/ruby_event_store/browser/app.rb @@ -40,23 +40,24 @@ def self.for( Rack::Builder.new do use Rack::Static, - urls: %w[ - bootstrap.js - ruby_event_store_browser.css - ruby_event_store_browser.js - android-chrome-192x192.png - android-chrome-512x512.png - apple-touch-icon.png - favicon.ico - favicon-16x16.png - favicon-32x32.png - mstile-70x70.png - mstile-144x144.png - mstile-150x150.png - mstile-310x150.png - mstile-310x310.png - safari-pinned-tab.svg - ].map {|f| ["/#{f}", f] }.to_h, + urls: + %w[ + bootstrap.js + ruby_event_store_browser.css + ruby_event_store_browser.js + android-chrome-192x192.png + android-chrome-512x512.png + apple-touch-icon.png + favicon.ico + favicon-16x16.png + favicon-32x32.png + mstile-70x70.png + mstile-144x144.png + mstile-150x150.png + mstile-310x150.png + mstile-310x310.png + safari-pinned-tab.svg + ].map { |f| ["/#{f}", f] }.to_h, root: "#{__dir__}/../../../public" run App.new( event_store_locator: event_store_locator, @@ -68,7 +69,13 @@ def self.for( end end - def initialize(event_store_locator:, related_streams_query:, host:, root_path:, api_url:) + def initialize( + event_store_locator:, + related_streams_query:, + host:, + root_path:, + api_url: + ) @event_store_locator = event_store_locator @related_streams_query = related_streams_query @routing = Urls.from_configuration(host, root_path, api_url) @@ -77,7 +84,10 @@ def initialize(event_store_locator:, related_streams_query:, host:, root_path:, def call(env) router = Router.new(routing) router.add_route("GET", "/api/events/:event_id") do |params| - json GetEvent.new(event_store: event_store, event_id: params.fetch("event_id")) + json GetEvent.new( + event_store: event_store, + event_id: params.fetch("event_id") + ) end router.add_route("GET", "/api/streams/:stream_name") do |params, urls| json GetStream.new( @@ -86,7 +96,10 @@ def call(env) related_streams_query: related_streams_query ) end - router.add_route("GET", "/api/streams/:stream_name/relationships/events") do |params, urls| + router.add_route( + "GET", + "/api/streams/:stream_name/relationships/events" + ) do |params, urls| json GetEventsFromStream.new( event_store: event_store, routing: urls, @@ -96,12 +109,17 @@ def call(env) end router.add_route("GET", "/api/search_streams/:stream_name") do |params| json SearchStreams.new( - event_store: event_store, - stream_name: params.fetch("stream_name"), - ) + event_store: event_store, + stream_name: params.fetch("stream_name") + ) end - %w[/ /events/:event_id /streams/:stream_name /debug].each do |starting_route| + %w[ + / + /events/:event_id + /streams/:stream_name + /debug + ].each do |starting_route| router.add_route("GET", starting_route) do |_, urls| erb bootstrap_html, browser_js_src: urls.browser_js_url, @@ -110,8 +128,7 @@ def call(env) initial_data: { rootUrl: urls.app_url, apiUrl: urls.api_url, - resVersion: res_version, - repositoryAdapter: repository_adapter + resVersion: res_version } end end @@ -156,20 +173,24 @@ def not_found end def json(body) - [200, { "content-type" => "application/vnd.api+json" }, [JSON.dump(body.to_h)]] + [ + 200, + { "content-type" => "application/vnd.api+json" }, + [JSON.dump(body.to_h)] + ] end def erb(template, **locals) - [200, { "content-type" => "text/html;charset=utf-8" }, [ERB.new(template).result_with_hash(locals)]] + [ + 200, + { "content-type" => "text/html;charset=utf-8" }, + [ERB.new(template).result_with_hash(locals)] + ] end def res_version RubyEventStore::VERSION end - - def repository_adapter - event_store.repository_specification - end end end end From af36acb4a5661398f20f1eef2abf876ead6d421d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Reszke?= Date: Thu, 25 Jul 2024 09:29:44 +0200 Subject: [PATCH 26/42] Revert "Debug module with its own model" This reverts commit 8a61cd9ca379d6d8d9495714ccd29597fab43ec1. --- ruby_event_store-browser/elm/src/Main.elm | 8 ++++---- ruby_event_store-browser/elm/src/Page/Debug.elm | 12 +++--------- 2 files changed, 7 insertions(+), 13 deletions(-) diff --git a/ruby_event_store-browser/elm/src/Main.elm b/ruby_event_store-browser/elm/src/Main.elm index 19f4f8ba14..b33008d0ca 100644 --- a/ruby_event_store-browser/elm/src/Main.elm +++ b/ruby_event_store-browser/elm/src/Main.elm @@ -56,7 +56,7 @@ type Page = NotFound | ShowEvent Page.ShowEvent.Model | ShowStream Page.ShowStream.Model - | Debug Page.Debug.Model + | Debug subscriptions : Model -> Sub Msg @@ -215,7 +215,7 @@ navigate model location = ( { model | page = NotFound }, Cmd.none ) Just (Route.Debug) -> - ( { model | page = Debug (Page.Debug.init flags.resVersion) }, Cmd.none ) + ( { model | page = Debug }, Cmd.none ) Nothing -> ( { model | page = NotFound }, Cmd.none ) @@ -269,10 +269,10 @@ viewPage page selectedTime = in ( Just title, Html.map GotShowEventMsg content ) - Debug pageModel -> + Debug -> let content = - Page.Debug.view pageModel + Page.Debug.view in ( Just "Debug", content ) diff --git a/ruby_event_store-browser/elm/src/Page/Debug.elm b/ruby_event_store-browser/elm/src/Page/Debug.elm index e75b0c2a85..2c4bd51d80 100644 --- a/ruby_event_store-browser/elm/src/Page/Debug.elm +++ b/ruby_event_store-browser/elm/src/Page/Debug.elm @@ -2,12 +2,6 @@ module Page.Debug exposing (..) import Html exposing (..) -type alias Model = { resVersion : String } - -init : String -> Model -init resVersion = - { resVersion = resVersion } - -view: Model -> Html a -view model = - text ("RubyEventStore version: " ++ model.resVersion) +view: Html a +view = + text "to be filled with some helpful content" From edeebb055bdd8c1839b72834ed0459d3685d6c2c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Reszke?= Date: Thu, 25 Jul 2024 09:30:13 +0200 Subject: [PATCH 27/42] Revert "move Debug page to separate module" This reverts commit 99cf19a3cb38fd251c22dcd0f288db14ea8e7c75. --- ruby_event_store-browser/elm/src/Main.elm | 7 +------ ruby_event_store-browser/elm/src/Page/Debug.elm | 7 ------- 2 files changed, 1 insertion(+), 13 deletions(-) delete mode 100644 ruby_event_store-browser/elm/src/Page/Debug.elm diff --git a/ruby_event_store-browser/elm/src/Main.elm b/ruby_event_store-browser/elm/src/Main.elm index b33008d0ca..e2187e2024 100644 --- a/ruby_event_store-browser/elm/src/Main.elm +++ b/ruby_event_store-browser/elm/src/Main.elm @@ -10,7 +10,6 @@ import Layout import LinkedTimezones exposing (mapLinkedTimeZone) import Page.ShowEvent import Page.ShowStream -import Page.Debug import Route import Task import Time @@ -270,11 +269,7 @@ viewPage page selectedTime = ( Just title, Html.map GotShowEventMsg content ) Debug -> - let - content = - Page.Debug.view - in - ( Just "Debug", content ) + ( Just "Debug", text "to be filled with some helpful content" ) NotFound -> ( Nothing, Layout.viewNotFound ) diff --git a/ruby_event_store-browser/elm/src/Page/Debug.elm b/ruby_event_store-browser/elm/src/Page/Debug.elm deleted file mode 100644 index 2c4bd51d80..0000000000 --- a/ruby_event_store-browser/elm/src/Page/Debug.elm +++ /dev/null @@ -1,7 +0,0 @@ -module Page.Debug exposing (..) - -import Html exposing (..) - -view: Html a -view = - text "to be filled with some helpful content" From 0e7183d1a07f50906b0647785235f79b7d044a58 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Reszke?= Date: Thu, 25 Jul 2024 09:31:12 +0200 Subject: [PATCH 28/42] Revert "initiate /debug browser page" This reverts commit 623c125ff3ce20bb8e150db2451a3d50293e93b4. --- ruby_event_store-browser/elm/src/Main.elm | 7 ---- ruby_event_store-browser/elm/src/Route.elm | 2 -- .../lib/ruby_event_store/browser/app.rb | 35 ++++++++----------- 3 files changed, 15 insertions(+), 29 deletions(-) diff --git a/ruby_event_store-browser/elm/src/Main.elm b/ruby_event_store-browser/elm/src/Main.elm index e2187e2024..d18aa4cab6 100644 --- a/ruby_event_store-browser/elm/src/Main.elm +++ b/ruby_event_store-browser/elm/src/Main.elm @@ -55,7 +55,6 @@ type Page = NotFound | ShowEvent Page.ShowEvent.Model | ShowStream Page.ShowStream.Model - | Debug subscriptions : Model -> Sub Msg @@ -213,9 +212,6 @@ navigate model location = Nothing -> ( { model | page = NotFound }, Cmd.none ) - Just (Route.Debug) -> - ( { model | page = Debug }, Cmd.none ) - Nothing -> ( { model | page = NotFound }, Cmd.none ) @@ -268,8 +264,5 @@ viewPage page selectedTime = in ( Just title, Html.map GotShowEventMsg content ) - Debug -> - ( Just "Debug", text "to be filled with some helpful content" ) - NotFound -> ( Nothing, Layout.viewNotFound ) diff --git a/ruby_event_store-browser/elm/src/Route.elm b/ruby_event_store-browser/elm/src/Route.elm index 6aa7599145..e50aa6a95d 100644 --- a/ruby_event_store-browser/elm/src/Route.elm +++ b/ruby_event_store-browser/elm/src/Route.elm @@ -12,7 +12,6 @@ import Url.Parser.Query as Query type Route = BrowseEvents String Pagination.Specification | ShowEvent String - | Debug decodeLocation : Url.Url -> Url.Url -> Maybe Route @@ -26,7 +25,6 @@ routeParser = [ Url.Parser.map (BrowseEvents "all" Pagination.empty) Url.Parser.top , Url.Parser.map browseEvents (Url.Parser.s "streams" Url.Parser.string Query.string "page[position]" Query.string "page[direction]" Query.string "page[count]") , Url.Parser.map ShowEvent (Url.Parser.s "events" Url.Parser.string) - , Url.Parser.map Debug (Url.Parser.s "debug" Url.Parser.top) ] diff --git a/ruby_event_store-browser/lib/ruby_event_store/browser/app.rb b/ruby_event_store-browser/lib/ruby_event_store/browser/app.rb index a27029f48c..53ba3a3a85 100644 --- a/ruby_event_store-browser/lib/ruby_event_store/browser/app.rb +++ b/ruby_event_store-browser/lib/ruby_event_store/browser/app.rb @@ -17,26 +17,26 @@ def self.for( related_streams_query: DEFAULT_RELATED_STREAMS_QUERY ) warn(<<~WARN) if environment - Passing :environment to RubyEventStore::Browser::App.for is deprecated. + Passing :environment to RubyEventStore::Browser::App.for is deprecated. - This option is no-op, has no effect and will be removed in next major release. - WARN + This option is no-op, has no effect and will be removed in next major release. + WARN warn(<<~WARN) if host - Passing :host to RubyEventStore::Browser::App.for is deprecated. + Passing :host to RubyEventStore::Browser::App.for is deprecated. - This option will be removed in next major release. - - Host and mount points are correctly recognized from Rack environment - and this option is redundant. - WARN + This option will be removed in next major release. + + Host and mount points are correctly recognized from Rack environment + and this option is redundant. + WARN warn(<<~WARN) if path - Passing :path to RubyEventStore::Browser::App.for is deprecated. + Passing :path to RubyEventStore::Browser::App.for is deprecated. - This option will be removed in next major release. + This option will be removed in next major release. - Host and mount points are correctly recognized from Rack environment - and this option is redundant. - WARN + Host and mount points are correctly recognized from Rack environment + and this option is redundant. + WARN Rack::Builder.new do use Rack::Static, @@ -114,12 +114,7 @@ def call(env) ) end - %w[ - / - /events/:event_id - /streams/:stream_name - /debug - ].each do |starting_route| + %w[/ /events/:event_id /streams/:stream_name].each do |starting_route| router.add_route("GET", starting_route) do |_, urls| erb bootstrap_html, browser_js_src: urls.browser_js_url, From 4a54baf288a86fbb4d57f196efe4f0a34bd19253 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Reszke?= Date: Thu, 25 Jul 2024 09:32:07 +0200 Subject: [PATCH 29/42] Revert "Kill mutant" This reverts commit 52e7a56be683aec39b003efb1fce901c1e6c23b4. --- ruby_event_store-active_record/spec/event_repository_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ruby_event_store-active_record/spec/event_repository_spec.rb b/ruby_event_store-active_record/spec/event_repository_spec.rb index 0ce7a87461..885ff21301 100644 --- a/ruby_event_store-active_record/spec/event_repository_spec.rb +++ b/ruby_event_store-active_record/spec/event_repository_spec.rb @@ -196,7 +196,7 @@ module ActiveRecord ) repository.append_to_stream( [SRecord.new(event_id: e3 = SecureRandom.uuid)], - s3 = Stream.new("dUmMY$#{e3}"), + s3 = Stream.new("Dummy$#{e3}"), ExpectedVersion.any ) From 4c5d3be1aee58278903d348989d5b0f521f9e60c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Reszke?= Date: Thu, 25 Jul 2024 09:32:14 +0200 Subject: [PATCH 30/42] Revert "lowercase" This reverts commit d22b979cca41bff080d5eb0b48488f46849a2b64. --- .../ruby_event_store/active_record/event_repository_reader.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ruby_event_store-active_record/lib/ruby_event_store/active_record/event_repository_reader.rb b/ruby_event_store-active_record/lib/ruby_event_store/active_record/event_repository_reader.rb index 8d65059017..73a69f7965 100644 --- a/ruby_event_store-active_record/lib/ruby_event_store/active_record/event_repository_reader.rb +++ b/ruby_event_store-active_record/lib/ruby_event_store/active_record/event_repository_reader.rb @@ -58,7 +58,7 @@ def event_in_stream?(event_id, stream) end def search_streams(stream) - @stream_klass.where("lower(stream) LIKE ?", "#{stream.downcase}%").order("position DESC, id DESC").pluck(:stream).map { |name| Stream.new(name) } + @stream_klass.where("stream LIKE ?", "#{stream}%").order("position DESC, id DESC").pluck(:stream).map { |name| Stream.new(name) } end private From 220f38ba7444a4631fafefa35ce542e039c99ebf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Reszke?= Date: Thu, 25 Jul 2024 09:33:27 +0200 Subject: [PATCH 31/42] Revert "search streams endpoint for browser" This reverts commit 2cb25fa1fee11858a4db93a0e3c94bcf54b2bc4e. --- .../lib/ruby_event_store/browser.rb | 1 - .../lib/ruby_event_store/browser/app.rb | 6 ---- .../browser/search_streams.rb | 26 ---------------- .../spec/api/search_streams_spec.rb | 30 ------------------- 4 files changed, 63 deletions(-) delete mode 100644 ruby_event_store-browser/lib/ruby_event_store/browser/search_streams.rb delete mode 100644 ruby_event_store-browser/spec/api/search_streams_spec.rb diff --git a/ruby_event_store-browser/lib/ruby_event_store/browser.rb b/ruby_event_store-browser/lib/ruby_event_store/browser.rb index 8b73ff80d2..c82d1cefce 100644 --- a/ruby_event_store-browser/lib/ruby_event_store/browser.rb +++ b/ruby_event_store-browser/lib/ruby_event_store/browser.rb @@ -13,7 +13,6 @@ module Browser require_relative "browser/json_api_stream" require_relative "browser/get_events_from_stream" require_relative "browser/get_stream" -require_relative "browser/search_streams" require_relative "browser/urls" require_relative "browser/gem_source" require_relative "browser/router" diff --git a/ruby_event_store-browser/lib/ruby_event_store/browser/app.rb b/ruby_event_store-browser/lib/ruby_event_store/browser/app.rb index 53ba3a3a85..b503c42bd3 100644 --- a/ruby_event_store-browser/lib/ruby_event_store/browser/app.rb +++ b/ruby_event_store-browser/lib/ruby_event_store/browser/app.rb @@ -107,12 +107,6 @@ def call(env) page: params["page"] ) end - router.add_route("GET", "/api/search_streams/:stream_name") do |params| - json SearchStreams.new( - event_store: event_store, - stream_name: params.fetch("stream_name") - ) - end %w[/ /events/:event_id /streams/:stream_name].each do |starting_route| router.add_route("GET", starting_route) do |_, urls| diff --git a/ruby_event_store-browser/lib/ruby_event_store/browser/search_streams.rb b/ruby_event_store-browser/lib/ruby_event_store/browser/search_streams.rb deleted file mode 100644 index 84aa4562d8..0000000000 --- a/ruby_event_store-browser/lib/ruby_event_store/browser/search_streams.rb +++ /dev/null @@ -1,26 +0,0 @@ -# frozen_string_literal: true - -module RubyEventStore - module Browser - class SearchStreams - def initialize(event_store:, stream_name:) - @event_store = event_store - @stream_name = stream_name - end - - def to_h - { - data: streams - } - end - - private - - def streams - event_store.search_streams(stream_name).map { |stream| { id: stream.name, type: "streams" } } - end - - attr_reader :event_store, :stream_name - end - end -end diff --git a/ruby_event_store-browser/spec/api/search_streams_spec.rb b/ruby_event_store-browser/spec/api/search_streams_spec.rb deleted file mode 100644 index 97a52a5c7c..0000000000 --- a/ruby_event_store-browser/spec/api/search_streams_spec.rb +++ /dev/null @@ -1,30 +0,0 @@ -require "spec_helper" - -module RubyEventStore - ::RSpec.describe Browser do - include Browser::IntegrationHelpers - - specify "something" do - event_store.publish(DummyEvent.new, stream_name: "dummy-1") - event_store.publish(DummyEvent.new, stream_name: "dummy-2") - - api_client.get "/api/search_streams/dum" - - expect(api_client.last_response).to be_ok - expect(api_client.parsed_body["data"]).to match_array( - [ - { "id" => "$by_type_DummyEvent", "type" => "streams" }, - { "id" => "dummy-2", "type" => "streams" }, - { "id" => "dummy-1", "type" => "streams" } - ] - ) - - api_client.get "/api/search_streams/dummy-" - - expect(api_client.last_response).to be_ok - expect(api_client.parsed_body["data"]).to match_array( - [{ "id" => "dummy-2", "type" => "streams" }, { "id" => "dummy-1", "type" => "streams" }] - ) - end - end -end From b6a1e5a8a64c635ce3de516a09a87254c1d3fefb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Reszke?= Date: Thu, 25 Jul 2024 09:33:38 +0200 Subject: [PATCH 32/42] Revert "Add search_streams in RubyEventStore::Client" This reverts commit 8a1d9f9ff16e0cf334e0846ca49b625b7c09444a. --- .../lib/ruby_event_store/client.rb | 4 ---- .../ruby_event_store/in_memory_repository.rb | 1 + ruby_event_store/spec/client_spec.rb | 21 ------------------- 3 files changed, 1 insertion(+), 25 deletions(-) diff --git a/ruby_event_store/lib/ruby_event_store/client.rb b/ruby_event_store/lib/ruby_event_store/client.rb index 3326c1c3ff..92aa1a9781 100644 --- a/ruby_event_store/lib/ruby_event_store/client.rb +++ b/ruby_event_store/lib/ruby_event_store/client.rb @@ -92,10 +92,6 @@ def streams_of(event_id) repository.streams_of(event_id) end - def search_streams(stream) - repository.search_streams(stream) - end - # Gets position of the event in given stream # # The position is always nonnegative. diff --git a/ruby_event_store/lib/ruby_event_store/in_memory_repository.rb b/ruby_event_store/lib/ruby_event_store/in_memory_repository.rb index fad6f0a89f..bc3ad5dd62 100644 --- a/ruby_event_store/lib/ruby_event_store/in_memory_repository.rb +++ b/ruby_event_store/lib/ruby_event_store/in_memory_repository.rb @@ -131,6 +131,7 @@ def search_streams(stream_name) .select { |name,| name.downcase.include?(stream_name.downcase) } .to_a .reverse + .to_h .map { |name,| Stream.new(name) } end diff --git a/ruby_event_store/spec/client_spec.rb b/ruby_event_store/spec/client_spec.rb index 637cbb2d61..d9a4a88b8b 100644 --- a/ruby_event_store/spec/client_spec.rb +++ b/ruby_event_store/spec/client_spec.rb @@ -840,27 +840,6 @@ module RubyEventStore end end - specify "finds streams that are similar to searching criteria" do - event_1 = OrderCreated.new(event_id: SecureRandom.uuid, data: {}) - event_2 = OrderCreated.new(event_id: SecureRandom.uuid, data: {}) - event_3 = OrderCreated.new(event_id: SecureRandom.uuid, data: {}) - stream_1 = Stream.new("stream-1") - stream_2 = Stream.new("stream-2") - stream_3 = Stream.new("stream-3") - - client.append(event_1, stream_name: stream_1.name) - client.append(event_2, stream_name: stream_2.name) - client.append(event_3, stream_name: stream_3.name) - - expect(client.search_streams("str")).to eq [stream_3, stream_2, stream_1] - expect(client.search_streams("Str")).to eq [stream_3, stream_2, stream_1] - expect(client.search_streams("sTr")).to eq [stream_3, stream_2, stream_1] - expect(client.search_streams("stream-1")).to eq [stream_1] - expect(client.search_streams("stream-2")).to eq [stream_2] - expect(client.search_streams("stream-3")).to eq [stream_3] - expect(client.search_streams("stream-4")).to eq [] - end - describe "#subscribers_for" do specify do handler = Subscribers::ValidHandler.new From 0c059a70ec1049ee6d9bc1c54658d038cf9dd6e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Reszke?= Date: Thu, 25 Jul 2024 09:33:52 +0200 Subject: [PATCH 33/42] Revert "Add search_streams to InMemoryRepository" This reverts commit 053dcd8ac5fa704abd66a6fe13bc98a52b458161. --- .../lib/ruby_event_store/in_memory_repository.rb | 9 --------- 1 file changed, 9 deletions(-) diff --git a/ruby_event_store/lib/ruby_event_store/in_memory_repository.rb b/ruby_event_store/lib/ruby_event_store/in_memory_repository.rb index bc3ad5dd62..3549d23373 100644 --- a/ruby_event_store/lib/ruby_event_store/in_memory_repository.rb +++ b/ruby_event_store/lib/ruby_event_store/in_memory_repository.rb @@ -126,15 +126,6 @@ def streams_of(event_id) streams.select { |name,| has_event_in_stream?(event_id, name) }.map { |name,| Stream.new(name) } end - def search_streams(stream_name) - streams - .select { |name,| name.downcase.include?(stream_name.downcase) } - .to_a - .reverse - .to_h - .map { |name,| Stream.new(name) } - end - def position_in_stream(event_id, stream) event_in_stream = streams[stream.name].find { |event_in_stream| event_in_stream.event_id.eql?(event_id) } raise EventNotFoundInStream if event_in_stream.nil? From 45714f8ef7bedfcc8c276f8bf8a088e328c471c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Reszke?= Date: Thu, 25 Jul 2024 09:33:58 +0200 Subject: [PATCH 34/42] Revert "Add search_streams test into event_repository_lint" This reverts commit af9e835833bbb5ea7d008622886369e605075092. --- .../spec/event_repository_lint.rb | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/ruby_event_store/lib/ruby_event_store/spec/event_repository_lint.rb b/ruby_event_store/lib/ruby_event_store/spec/event_repository_lint.rb index 25e4e5a9ba..faebee594f 100644 --- a/ruby_event_store/lib/ruby_event_store/spec/event_repository_lint.rb +++ b/ruby_event_store/lib/ruby_event_store/spec/event_repository_lint.rb @@ -1184,24 +1184,6 @@ def read_events_backward(repository, stream = nil, from: nil, to: nil, count: ni expect(repository.streams_of("d10c8fe9-2163-418d-ba47-88c9a1f9391b")).to eq [] end - specify do - event_1 = SRecord.new(event_id: "8a6f053e-3ce2-4c82-a55b-4d02c66ae6ea") - event_2 = SRecord.new(event_id: "8cee1139-4f96-483a-a175-2b947283c3c7") - event_3 = SRecord.new(event_id: "d345f86d-b903-4d78-803f-38990c078d9e") - stream_a = Stream.new("Stream A") - stream_b = Stream.new("Stream B") - stream_c = Stream.new("Stream C") - repository.append_to_stream([event_1], stream_a, version_any) - repository.append_to_stream([event_2], stream_b, version_any) - repository.append_to_stream([event_3], stream_c, version_any) - - expect(repository.search_streams("str")).to eq [stream_c, stream_b, stream_a] - expect(repository.search_streams("Str")).to eq [stream_c, stream_b, stream_a] - expect(repository.search_streams("Stream A")).to eq [stream_a] - expect(repository.search_streams("Stream B")).to eq [stream_b] - expect(repository.search_streams("Stream C")).to eq [stream_c] - end - specify do e1 = SRecord.new(event_id: "8a6f053e-3ce2-4c82-a55b-4d02c66ae6ea") e2 = SRecord.new(event_id: "8cee1139-4f96-483a-a175-2b947283c3c7") From aed52a04692dbe503934a8640f8f7af529a35633 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Reszke?= Date: Thu, 25 Jul 2024 09:34:03 +0200 Subject: [PATCH 35/42] Revert "Reverse results order" This reverts commit 0c68d7e85c8dc6615aa7024c45ab8707c8f18cd6. --- .../active_record/event_repository_reader.rb | 2 +- .../spec/event_repository_spec.rb | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/ruby_event_store-active_record/lib/ruby_event_store/active_record/event_repository_reader.rb b/ruby_event_store-active_record/lib/ruby_event_store/active_record/event_repository_reader.rb index 73a69f7965..99b96beae1 100644 --- a/ruby_event_store-active_record/lib/ruby_event_store/active_record/event_repository_reader.rb +++ b/ruby_event_store-active_record/lib/ruby_event_store/active_record/event_repository_reader.rb @@ -58,7 +58,7 @@ def event_in_stream?(event_id, stream) end def search_streams(stream) - @stream_klass.where("stream LIKE ?", "#{stream}%").order("position DESC, id DESC").pluck(:stream).map { |name| Stream.new(name) } + @stream_klass.where("stream LIKE ?", "#{stream}%").order("position ASC").pluck(:stream).map { |name| Stream.new(name) } end private diff --git a/ruby_event_store-active_record/spec/event_repository_spec.rb b/ruby_event_store-active_record/spec/event_repository_spec.rb index 885ff21301..7cee0a75b2 100644 --- a/ruby_event_store-active_record/spec/event_repository_spec.rb +++ b/ruby_event_store-active_record/spec/event_repository_spec.rb @@ -200,12 +200,12 @@ module ActiveRecord ExpectedVersion.any ) - expect(repository.search_streams("Du")).to eq([s3, s2, s1]) - expect(repository.search_streams("du")).to eq([s3, s2, s1]) - expect(repository.search_streams("dum")).to eq([s3, s2, s1]) - expect(repository.search_streams("dumm")).to eq([s3, s2, s1]) - expect(repository.search_streams("dummy")).to eq([s3, s2, s1]) - expect(repository.search_streams("Dummy")).to eq([s3, s2, s1]) + expect(repository.search_streams("Du")).to eq([s1, s2, s3]) + expect(repository.search_streams("du")).to eq([s1, s2, s3]) + expect(repository.search_streams("dum")).to eq([s1, s2, s3]) + expect(repository.search_streams("dumm")).to eq([s1, s2, s3]) + expect(repository.search_streams("dummy")).to eq([s1, s2, s3]) + expect(repository.search_streams("Dummy")).to eq([s1, s2, s3]) end specify "finds no streams when search phrase doesn't match anything" do From 7d86caa82fc9543abbeb8c2a08ee9f288e046569 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Reszke?= Date: Thu, 25 Jul 2024 09:34:11 +0200 Subject: [PATCH 36/42] Revert "Return stream object instead of name" This reverts commit a7e2e559ca8010231359890d4fc9cfd43f2d10f7. --- .../active_record/event_repository_reader.rb | 2 +- .../spec/event_repository_spec.rb | 18 +++++++++--------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/ruby_event_store-active_record/lib/ruby_event_store/active_record/event_repository_reader.rb b/ruby_event_store-active_record/lib/ruby_event_store/active_record/event_repository_reader.rb index 99b96beae1..4fe46d2af1 100644 --- a/ruby_event_store-active_record/lib/ruby_event_store/active_record/event_repository_reader.rb +++ b/ruby_event_store-active_record/lib/ruby_event_store/active_record/event_repository_reader.rb @@ -58,7 +58,7 @@ def event_in_stream?(event_id, stream) end def search_streams(stream) - @stream_klass.where("stream LIKE ?", "#{stream}%").order("position ASC").pluck(:stream).map { |name| Stream.new(name) } + @stream_klass.where("stream LIKE ?", "#{stream}%").pluck(:stream).uniq end private diff --git a/ruby_event_store-active_record/spec/event_repository_spec.rb b/ruby_event_store-active_record/spec/event_repository_spec.rb index 7cee0a75b2..65bb504739 100644 --- a/ruby_event_store-active_record/spec/event_repository_spec.rb +++ b/ruby_event_store-active_record/spec/event_repository_spec.rb @@ -186,26 +186,26 @@ module ActiveRecord 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}"), + Stream.new("Dummy$#{e1}"), ExpectedVersion.any ) repository.append_to_stream( [SRecord.new(event_id: e2 = SecureRandom.uuid)], - s2 = Stream.new("Dummy$#{e2}"), + Stream.new("Dummy$#{e2}"), ExpectedVersion.any ) repository.append_to_stream( [SRecord.new(event_id: e3 = SecureRandom.uuid)], - s3 = Stream.new("Dummy$#{e3}"), + Stream.new("Dummy$#{e3}"), ExpectedVersion.any ) - expect(repository.search_streams("Du")).to eq([s1, s2, s3]) - expect(repository.search_streams("du")).to eq([s1, s2, s3]) - expect(repository.search_streams("dum")).to eq([s1, s2, s3]) - expect(repository.search_streams("dumm")).to eq([s1, s2, s3]) - expect(repository.search_streams("dummy")).to eq([s1, s2, s3]) - expect(repository.search_streams("Dummy")).to eq([s1, s2, s3]) + 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 From 7b59b9cf12430912e310c2e226616a34903bbeab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Reszke?= Date: Thu, 25 Jul 2024 09:34:18 +0200 Subject: [PATCH 37/42] Revert "Introduce search_streams in EventRepository" This reverts commit e930fbfdea6a5675777f82db6309d7ae78ba27f2. --- .../active_record/event_repository.rb | 4 -- .../active_record/event_repository_reader.rb | 4 -- .../spec/event_repository_spec.rb | 51 ------------------- 3 files changed, 59 deletions(-) diff --git a/ruby_event_store-active_record/lib/ruby_event_store/active_record/event_repository.rb b/ruby_event_store-active_record/lib/ruby_event_store/active_record/event_repository.rb index 4ef9a72b35..611afb93c1 100644 --- a/ruby_event_store-active_record/lib/ruby_event_store/active_record/event_repository.rb +++ b/ruby_event_store-active_record/lib/ruby_event_store/active_record/event_repository.rb @@ -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) diff --git a/ruby_event_store-active_record/lib/ruby_event_store/active_record/event_repository_reader.rb b/ruby_event_store-active_record/lib/ruby_event_store/active_record/event_repository_reader.rb index 4fe46d2af1..0a1d4eae52 100644 --- a/ruby_event_store-active_record/lib/ruby_event_store/active_record/event_repository_reader.rb +++ b/ruby_event_store-active_record/lib/ruby_event_store/active_record/event_repository_reader.rb @@ -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 diff --git a/ruby_event_store-active_record/spec/event_repository_spec.rb b/ruby_event_store-active_record/spec/event_repository_spec.rb index 65bb504739..dfd8bc9466 100644 --- a/ruby_event_store-active_record/spec/event_repository_spec.rb +++ b/ruby_event_store-active_record/spec/event_repository_spec.rb @@ -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( [ From c653326b867d730485c6d5966737817d1b936c56 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Reszke?= Date: Thu, 25 Jul 2024 09:37:15 +0200 Subject: [PATCH 38/42] Revert "Show real repository adapter on Debug page" This reverts commit 89d0275dbaf2fb60cac430a5ef8e6d5b74c75714. --- .../ruby_event_store/active_record/event_repository.rb | 4 ---- ruby_event_store/lib/ruby_event_store/client.rb | 8 -------- 2 files changed, 12 deletions(-) diff --git a/ruby_event_store-active_record/lib/ruby_event_store/active_record/event_repository.rb b/ruby_event_store-active_record/lib/ruby_event_store/active_record/event_repository.rb index 611afb93c1..931e095d5b 100644 --- a/ruby_event_store-active_record/lib/ruby_event_store/active_record/event_repository.rb +++ b/ruby_event_store-active_record/lib/ruby_event_store/active_record/event_repository.rb @@ -81,10 +81,6 @@ def event_in_stream?(event_id, stream) @repo_reader.event_in_stream?(event_id, stream) end - def specification - "#{self.class.name} with #{::ActiveRecord::Base.connection.adapter_name} db adapter" - end - private attr_reader :serializer diff --git a/ruby_event_store/lib/ruby_event_store/client.rb b/ruby_event_store/lib/ruby_event_store/client.rb index 92aa1a9781..0ed4217195 100644 --- a/ruby_event_store/lib/ruby_event_store/client.rb +++ b/ruby_event_store/lib/ruby_event_store/client.rb @@ -230,14 +230,6 @@ def call unsubs.each(&:call) if unsubs end - def repository_specification - if repository.respond_to?(:specification) - repository.specification - else - repository.class.to_s - end - end - private attr_reader :resolver From e470c8f8228aae061f402c6bc17e9ef47923316c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Reszke?= Date: Thu, 25 Jul 2024 10:19:20 +0200 Subject: [PATCH 39/42] Remove search streams left overs It would kill the server in production environment --- ruby_event_store-browser/elm/src/Api.elm | 28 +----- ruby_event_store-browser/elm/src/Layout.elm | 36 +------- ruby_event_store-browser/elm/src/Search.elm | 91 +------------------ .../elm/tests/DecodersTest.elm | 32 +------ .../elm/tests/SearchTest.elm | 38 -------- 5 files changed, 8 insertions(+), 217 deletions(-) delete mode 100644 ruby_event_store-browser/elm/tests/SearchTest.elm diff --git a/ruby_event_store-browser/elm/src/Api.elm b/ruby_event_store-browser/elm/src/Api.elm index 6ed645f59a..b1b597a0fb 100644 --- a/ruby_event_store-browser/elm/src/Api.elm +++ b/ruby_event_store-browser/elm/src/Api.elm @@ -1,4 +1,4 @@ -module Api exposing (Event, PaginatedList, PaginationLink, PaginationLinks, RemoteResource(..), SearchStream, Stream, emptyPaginatedList, eventDecoder, eventsDecoder, getEvent, getEvents, getSearchStreams, getStream, searchStreamsDecoder) +module Api exposing (Event, PaginatedList, PaginationLink, PaginationLinks, RemoteResource(..), Stream, emptyPaginatedList, eventDecoder, eventsDecoder, getEvent, getEvents, getStream) import Flags exposing (Flags) import Http @@ -38,10 +38,6 @@ type alias Event = } -type alias SearchStream = - { streamId : String - } - type alias PaginatedList a = { pagination : Pagination.Specification @@ -89,10 +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 - getEvent : (Result Http.Error Event -> msg) -> Flags -> String -> Cmd msg getEvent msgBuilder flags eventId = @@ -110,13 +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 - } - eventDecoder : Decoder Event eventDecoder = @@ -172,17 +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" - linksDecoder : Decoder PaginationLinks linksDecoder = diff --git a/ruby_event_store-browser/elm/src/Layout.elm b/ruby_event_store-browser/elm/src/Layout.elm index f3ca796810..b0be42a2ec 100644 --- a/ruby_event_store-browser/elm/src/Layout.elm +++ b/ruby_event_store-browser/elm/src/Layout.elm @@ -1,6 +1,5 @@ port module Layout exposing (Model, Msg, buildModel, subscriptions, update, view, viewIncorrectConfig, viewNotFound) -import Api exposing (SearchStream, getSearchStreams) import Browser exposing (Document) import Browser.Navigation import BrowserTime @@ -25,9 +24,7 @@ type Msg | SearchMsg Search.Msg | ToggleBookmarksMenu | ToggleDialog - | SearchedStreamsFetched (Result Http.Error (List SearchStream)) | OnSelect Search.Stream - | OnQueryChanged Search.Stream | RequestSearch | RequestSearchClose | ToggleBookmark String @@ -73,7 +70,7 @@ subscriptions = buildModel : Model buildModel = { search = - Search.init OnSelect OnQueryChanged + Search.init OnSelect , displayBookmarksMenu = False , bookmarks = [ { itemType = "Stream", label = "Bookmark 1", link = "/" } @@ -87,11 +84,6 @@ goToStream { key, flags } stream = Browser.Navigation.pushUrl key (Route.streamUrl flags.rootUrl stream) -searchStreams : WrappedModel Model -> String -> Cmd Msg -searchStreams { flags } stream = - getSearchStreams SearchedStreamsFetched flags stream - - update : Msg -> WrappedModel Model -> ( WrappedModel Model, Cmd Msg ) update msg model = case msg of @@ -110,9 +102,6 @@ update msg model = ] ) - OnQueryChanged streamName -> - ( model, searchStreams model streamName ) - TimeZoneSelected zoneName -> let defaultTimeZone = @@ -162,29 +151,6 @@ update msg model = ToggleDialog -> ( model, toggleDialog searchModalId ) - SearchedStreamsFetched (Ok streams) -> - let - streams_ = - List.map .streamId streams - - searchModel = - model.internal.search - - newModel = - { searchModel | streams = streams_ } - in - ( { model | internal = Model newModel model.internal.displayBookmarksMenu model.internal.bookmarks }, Cmd.none ) - - SearchedStreamsFetched (Err _) -> - let - searchModel = - model.internal.search - - newModel = - { searchModel | streams = [] } - in - ( { model | internal = Model newModel model.internal.displayBookmarksMenu model.internal.bookmarks }, Cmd.none ) - ToggleBookmark id -> ( model, toggleBookmark id ) diff --git a/ruby_event_store-browser/elm/src/Search.elm b/ruby_event_store-browser/elm/src/Search.elm index 69e1a9d8dd..75cee7a27c 100644 --- a/ruby_event_store-browser/elm/src/Search.elm +++ b/ruby_event_store-browser/elm/src/Search.elm @@ -13,10 +13,8 @@ type alias Stream = type alias Model a = - { streams : List Stream - , searchedStream : Stream + { searchedStream : Stream , onSelectMsg : Stream -> a - , onQueryMsg : Stream -> a } @@ -35,12 +33,10 @@ emptyStreams = [] -init : (Stream -> a) -> (Stream -> a) -> Model a -init onSelectMsg onQueryMsg = - { streams = emptyStreams - , searchedStream = emptyStreamName +init : (Stream -> a) -> Model a +init onSelectMsg = + { searchedStream = emptyStreamName , onSelectMsg = onSelectMsg - , onQueryMsg = onQueryMsg } @@ -49,27 +45,11 @@ onSelectCmd onSelectMsg stream = Task.perform onSelectMsg (Task.succeed stream) -onQueryChangedCmd : (Stream -> a) -> Stream -> Cmd a -onQueryChangedCmd onQueryMsg stream = - Task.perform onQueryMsg (Task.succeed stream) - - -hasAtLeastThreeChars : Stream -> Bool -hasAtLeastThreeChars stream = - String.length stream >= 3 - - update : Msg -> Model a -> ( Model a, Cmd a ) update msg model = case msg of StreamChanged stream -> - if hasAtLeastThreeChars stream then - ( { model | searchedStream = stream } - , onQueryChangedCmd model.onQueryMsg stream - ) - - else - ( { model | searchedStream = stream }, Cmd.none ) + ( { model | searchedStream = stream }, Cmd.none ) GoToStream stream -> ( { model | searchedStream = emptyStreamName } @@ -77,37 +57,8 @@ update msg model = ) -caseInsensitiveContains : Stream -> Stream -> Maybe Stream -caseInsensitiveContains needle haystack = - let - needleLower = - String.toLower needle - - haystackLower = - String.toLower haystack - in - if String.contains needleLower haystackLower then - Just haystack - - else - Nothing - - -filterStreams : Stream -> List Stream -> List Stream -filterStreams stream streams = - if String.isEmpty stream then - emptyStreams - - else - List.filterMap (caseInsensitiveContains stream) streams - - view : Model a -> Html Msg view model = - let - streams_ = - filterStreams model.searchedStream model.streams - in form [ onSubmit (GoToStream model.searchedStream) ] [ div [ class "relative" ] [ FeatherIcons.search @@ -125,36 +76,4 @@ view model = [ span [ class "text-gray-500 bg-gray-50 font-bold block p-1 border border-gray-300 rounded " ] [ text "ESC" ] ] ] - , viewStreamList streams_ - ] - - -streamsPresent : List Stream -> Bool -streamsPresent streams = - not <| List.isEmpty streams - - -viewStreamList : List Stream -> Html Msg -viewStreamList streams = - if streams |> streamsPresent then - div - [] - [ ul - [ class "mt-4 overflow-auto space-y-2 w-full" ] - (List.map viewStreamListItem streams) - ] - - else - text "" - - -viewStreamListItem : Stream -> Html Msg -viewStreamListItem stream = - li [] - [ a - [ class "p-3 block rounded hover:bg-red-200 w-full bg-gray-100 break-words text-xs font-bold font-mono" - , href ("/streams/" ++ stream) - , onClick (GoToStream stream) - ] - [ text stream ] ] diff --git a/ruby_event_store-browser/elm/tests/DecodersTest.elm b/ruby_event_store-browser/elm/tests/DecodersTest.elm index add018c5d7..a90afd1aa4 100644 --- a/ruby_event_store-browser/elm/tests/DecodersTest.elm +++ b/ruby_event_store-browser/elm/tests/DecodersTest.elm @@ -1,6 +1,6 @@ module DecodersTest exposing (suite) -import Api exposing (eventDecoder, eventsDecoder, searchStreamsDecoder) +import Api exposing (eventDecoder, eventsDecoder) import Expect import Json.Decode import Pagination @@ -143,35 +143,5 @@ suite = , validAt = Time.millisToPosix 1513813785273 } ) - , test "search decoder" <| - \_ -> - let - input = - """ - { - "data": [ - { - "id": "$by_tenant_id_133", - "type": "streams" - }, - { - "id": "$by_tenant_id_444", - "type": "streams" - } - ] - } - """ - - output = - Json.Decode.decodeString searchStreamsDecoder input - in - Expect.equal output - (Ok - [ { streamId = "$by_tenant_id_133" - } - , { streamId = "$by_tenant_id_444" - } - ] - ) ] ] diff --git a/ruby_event_store-browser/elm/tests/SearchTest.elm b/ruby_event_store-browser/elm/tests/SearchTest.elm deleted file mode 100644 index 19b53ddd74..0000000000 --- a/ruby_event_store-browser/elm/tests/SearchTest.elm +++ /dev/null @@ -1,38 +0,0 @@ -module SearchTest exposing (suite) - -import Expect -import Search exposing (filterStreams) -import Test exposing (..) - - -suite : Test -suite = - describe "Suite" - [ describe "filter streams" <| - [ test "filterStreams starting with" <| - \_ -> - Expect.equal - [ "DummyStream$78", "DummyStream$79" ] - (filterStreams "Dum" [ "DummyStream$78", "DummyStream$79" ]) - , test "filterStreams empty" <| - \_ -> - Expect.equal - [] - (filterStreams "" [ "DummyStream$78", "DummyStream$79" ]) - , test "filterStreams non matching" <| - \_ -> - Expect.equal - [] - (filterStreams "foo" [ "DummyStream$78", "DummyStream$79" ]) - , test "filterStreams ending with" <| - \_ -> - Expect.equal - [ "DummyStream$78" ] - (filterStreams "78" [ "DummyStream$78", "DummyStream$79" ]) - , test "filterStreams is case insensitive" <| - \_ -> - Expect.equal - [ "DummyStream$78", "DummyStream$79" ] - (filterStreams "stream" [ "DummyStream$78", "DummyStream$79" ]) - ] - ] From fbdad5deb7a5e5873f69c5aa3fcb228d1fcf4f05 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Reszke?= Date: Thu, 25 Jul 2024 10:59:03 +0200 Subject: [PATCH 40/42] Revert bookmarks --- ruby_event_store-browser/elm/src/Layout.elm | 71 +------------------- ruby_event_store-browser/public/bootstrap.js | 11 --- 2 files changed, 2 insertions(+), 80 deletions(-) diff --git a/ruby_event_store-browser/elm/src/Layout.elm b/ruby_event_store-browser/elm/src/Layout.elm index b0be42a2ec..56dec4d5af 100644 --- a/ruby_event_store-browser/elm/src/Layout.elm +++ b/ruby_event_store-browser/elm/src/Layout.elm @@ -22,25 +22,14 @@ import WrappedModel exposing (..) type Msg = TimeZoneSelected String | SearchMsg Search.Msg - | ToggleBookmarksMenu | ToggleDialog | OnSelect Search.Stream | RequestSearch | RequestSearchClose - | ToggleBookmark String type alias Model = { search : Search.Model Msg - , displayBookmarksMenu : Bool - , bookmarks : List Bookmark - } - - -type alias Bookmark = - { label : String - , link : String - , itemType : String } @@ -56,9 +45,6 @@ port requestSearchClose : (() -> msg) -> Sub msg port closeSearch : String -> Cmd msg -port toggleBookmark : String -> Cmd msg - - subscriptions : Sub Msg subscriptions = Sub.batch @@ -71,11 +57,6 @@ buildModel : Model buildModel = { search = Search.init OnSelect - , displayBookmarksMenu = False - , bookmarks = - [ { itemType = "Stream", label = "Bookmark 1", link = "/" } - , { itemType = "Stream", label = "Bookmark 2", link = "/" } - ] } @@ -92,7 +73,7 @@ update msg model = ( newSearch, cmd ) = Search.update searchMsg model.internal.search in - ( { model | internal = Model newSearch model.internal.displayBookmarksMenu model.internal.bookmarks }, cmd ) + ( { model | internal = Model newSearch }, cmd ) OnSelect streamName -> ( model @@ -145,15 +126,9 @@ update msg model = RequestSearchClose -> ( model, closeSearch searchModalId ) - ToggleBookmarksMenu -> - ( { model | internal = Model model.internal.search (not model.internal.displayBookmarksMenu) model.internal.bookmarks }, Cmd.none ) - ToggleDialog -> ( model, toggleDialog searchModalId ) - ToggleBookmark id -> - ( model, toggleBookmark id ) - view : (Msg -> a) -> WrappedModel Model -> Html a -> Html a view layoutMsgBuilder model pageView = @@ -197,7 +172,7 @@ browserNavigation model = ] , div [ class "flex items-center gap-2" ] - [ fakeSearchInput model.flags.platform, bookmarksMenu model ] + [ fakeSearchInput model.flags.platform ] ] @@ -243,48 +218,6 @@ timeZoneSelect time = (availableTimeZones time.detected |> List.map mkOption) -visibleBookmarksMenu : Bool -> String -visibleBookmarksMenu displayBookmarksMenu = - if displayBookmarksMenu then - "block" - - else - "hidden" - - -bookmarkToHtml : Bookmark -> Html Msg -bookmarkToHtml bookmark = - li [ class "flex hover:bg-gray-50 group pr-2" ] - [ a [ href bookmark.link, class "whitespace-nowrap py-2 block pl-4 pr-3" ] - [ text bookmark.label ] - , button [ title "Remove bookmark", class "group-hover:visible invisible text-gray-300 hover:text-gray-800", onClick (ToggleBookmark bookmark.link) ] - [ FeatherIcons.trash2 - |> FeatherIcons.withClass "size-4" - |> FeatherIcons.toHtml [] - ] - ] - - -bookmarksMenu : WrappedModel Model -> Html Msg -bookmarksMenu model = - div [ class "relative" ] - [ button - [ onClick ToggleBookmarksMenu - , class "text-red-100 outline-none text-sm flex gap-2 items-center bg-red-800 hover:bg-red-900 h-9 px-3 rounded" - ] - [ FeatherIcons.bookmark - |> FeatherIcons.withClass "size-4" - |> FeatherIcons.toHtml [] - ] - , div [ class ("absolute translate-y-4 right-0 top-full bg-white shadow rounded-sm" ++ " " ++ visibleBookmarksMenu model.internal.displayBookmarksMenu) ] - [ model.internal.bookmarks - |> List.map bookmarkToHtml - |> ul [ class "text-gray-800 text-sm" ] - , button [ onClick (ToggleBookmark "hi") ] [ text "Add bookmark here" ] - ] - ] - - fakeSearchInput : String -> Html Msg fakeSearchInput platform = button diff --git a/ruby_event_store-browser/public/bootstrap.js b/ruby_event_store-browser/public/bootstrap.js index 7669f23bea..e678d0c370 100644 --- a/ruby_event_store-browser/public/bootstrap.js +++ b/ruby_event_store-browser/public/bootstrap.js @@ -26,14 +26,3 @@ window.addEventListener("keydown", function (event) { event.preventDefault(); } }); - -app.ports.toggleBookmark.subscribe(function (id) { - const bookmarks = JSON.parse(localStorage.getItem("bookmarks")) || []; - if (bookmarks.indexOf(id) >= 0) { - bookmarks.splice(bookmarks.indexOf(id), 1); - } else { - bookmarks.push(id); - } - console.log(bookmarks); - localStorage.setItem("bookmarks", JSON.stringify(bookmarks)); -}); From 442e2722b8263c46e593bed6832d41128fcc09d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Reszke?= Date: Thu, 25 Jul 2024 11:13:21 +0200 Subject: [PATCH 41/42] format --- ruby_event_store-browser/public/bootstrap.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ruby_event_store-browser/public/bootstrap.js b/ruby_event_store-browser/public/bootstrap.js index e678d0c370..7f339ed9ec 100644 --- a/ruby_event_store-browser/public/bootstrap.js +++ b/ruby_event_store-browser/public/bootstrap.js @@ -1,6 +1,8 @@ -const flags = JSON.parse(document.querySelector("meta[name='ruby-event-store-browser-settings']").getAttribute("content")); +const flags = JSON.parse( + document.querySelector("meta[name='ruby-event-store-browser-settings']").getAttribute("content") +); flags.platform = navigator.platform; -const app = Elm.Main.init({flags}); +const app = Elm.Main.init({ flags }); app.ports.copyToClipboard.subscribe(function (message) { navigator.clipboard.writeText(message); From b18b6b887a8870685ca8c298d8916cc8b9de0cce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Reszke?= Date: Thu, 25 Jul 2024 11:17:44 +0200 Subject: [PATCH 42/42] Rename There is no more search, therefore this variable isn't correct anymore --- ruby_event_store-browser/elm/src/Search.elm | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/ruby_event_store-browser/elm/src/Search.elm b/ruby_event_store-browser/elm/src/Search.elm index 75cee7a27c..091236e1cf 100644 --- a/ruby_event_store-browser/elm/src/Search.elm +++ b/ruby_event_store-browser/elm/src/Search.elm @@ -13,7 +13,7 @@ type alias Stream = type alias Model a = - { searchedStream : Stream + { stream : Stream , onSelectMsg : Stream -> a } @@ -35,7 +35,7 @@ emptyStreams = init : (Stream -> a) -> Model a init onSelectMsg = - { searchedStream = emptyStreamName + { stream = emptyStreamName , onSelectMsg = onSelectMsg } @@ -49,24 +49,24 @@ update : Msg -> Model a -> ( Model a, Cmd a ) update msg model = case msg of StreamChanged stream -> - ( { model | searchedStream = stream }, Cmd.none ) + ( { model | stream = stream }, Cmd.none ) GoToStream stream -> - ( { model | searchedStream = emptyStreamName } + ( { model | stream = emptyStreamName } , onSelectCmd model.onSelectMsg stream ) view : Model a -> Html Msg view model = - form [ onSubmit (GoToStream model.searchedStream) ] + form [ onSubmit (GoToStream model.stream) ] [ div [ class "relative" ] [ FeatherIcons.search |> FeatherIcons.withClass "size-4 text-gray-400 absolute pointer-events-none top-3.5 left-2" |> FeatherIcons.toHtml [] , input [ class "rounded text-gray-800 cursor-pointer pl-8 pr-12 py-2 w-full appearance-none outline-none focus:ring-2 focus:ring-red-500 focus:ring-opacity-50" - , value model.searchedStream + , value model.stream , onInput StreamChanged , placeholder "Quick search…" , autofocus True