ruby_event_store-active_record 2.7.0 → 2.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bdabc01585e316bdc346af6b70751ff948c9d47e0cc10e08eabb0541f387fc68
|
4
|
+
data.tar.gz: 52a70e45996c0bedf4b7472fafaa1e3b655e126ce7c926ac6f0b0dc5314e55f1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 82a515a643f3f8bbad68d88e691dc687057e7f66ae7ab4a34567433c169208c47b3fcdf8fb37a8521808600d680386833e28357fa55d850667284d071e7e2a12
|
7
|
+
data.tar.gz: 67c3a32693f03ed905f40ee74b3d31a57b08f12c326cbd5ca9de28e4a062693b76b3d17cd4499093e5d0f3f3f7359a5a3226a95f53306af4945a2a2a6a3e6508
|
@@ -85,7 +85,8 @@ module RubyEventStore
|
|
85
85
|
stream = @event_klass
|
86
86
|
stream = stream.where(event_id: spec.with_ids) if spec.with_ids?
|
87
87
|
stream = stream.where(event_type: spec.with_types) if spec.with_types?
|
88
|
-
stream =
|
88
|
+
stream = stream.order(as_at(spec)) if spec.time_sort_by_as_at?
|
89
|
+
stream = stream.order(as_of(spec)) if spec.time_sort_by_as_of?
|
89
90
|
stream = stream.limit(spec.limit) if spec.limit?
|
90
91
|
stream = stream.where(start_condition_in_global_stream(spec)) if spec.start
|
91
92
|
stream = stream.where(stop_condition_in_global_stream(spec)) if spec.stop
|
@@ -97,29 +98,27 @@ module RubyEventStore
|
|
97
98
|
else
|
98
99
|
stream = @stream_klass.preload(:event).where(stream: spec.stream.name)
|
99
100
|
stream = stream.where(event_id: spec.with_ids) if spec.with_ids?
|
100
|
-
stream = stream.where(@event_klass.table_name => { event_type: spec.with_types }) if spec.with_types?
|
101
|
-
stream =
|
101
|
+
stream = stream.joins(:event).where(@event_klass.table_name => { event_type: spec.with_types }) if spec.with_types?
|
102
|
+
stream = stream.joins(:event).order(as_at(spec)) if spec.time_sort_by_as_at?
|
103
|
+
stream = stream.joins(:event).order(as_of(spec)) if spec.time_sort_by_as_of?
|
102
104
|
stream = stream.order(id: order(spec))
|
103
105
|
stream = stream.limit(spec.limit) if spec.limit?
|
104
106
|
stream = stream.where(start_condition(spec)) if spec.start
|
105
107
|
stream = stream.where(stop_condition(spec)) if spec.stop
|
106
|
-
stream = stream.where(older_than_condition(spec)) if spec.older_than
|
107
|
-
stream = stream.where(older_than_or_equal_condition(spec)) if spec.older_than_or_equal
|
108
|
-
stream = stream.where(newer_than_condition(spec)) if spec.newer_than
|
109
|
-
stream = stream.where(newer_than_or_equal_condition(spec)) if spec.newer_than_or_equal
|
108
|
+
stream = stream.joins(:event).where(older_than_condition(spec)) if spec.older_than
|
109
|
+
stream = stream.joins(:event).where(older_than_or_equal_condition(spec)) if spec.older_than_or_equal
|
110
|
+
stream = stream.joins(:event).where(newer_than_condition(spec)) if spec.newer_than
|
111
|
+
stream = stream.joins(:event).where(newer_than_or_equal_condition(spec)) if spec.newer_than_or_equal
|
110
112
|
stream
|
111
113
|
end
|
112
114
|
end
|
113
115
|
|
114
|
-
def
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
else
|
121
|
-
stream
|
122
|
-
end
|
116
|
+
def as_of(spec)
|
117
|
+
Arel.sql("COALESCE(#{@event_klass.table_name}.valid_at, #{@event_klass.table_name}.created_at) #{order(spec)}")
|
118
|
+
end
|
119
|
+
|
120
|
+
def as_at(spec)
|
121
|
+
"#{@event_klass.table_name}.created_at #{order(spec)}"
|
123
122
|
end
|
124
123
|
|
125
124
|
def start_offset_condition(specification, record_id, search_in)
|
@@ -164,20 +163,28 @@ module RubyEventStore
|
|
164
163
|
)
|
165
164
|
end
|
166
165
|
|
166
|
+
def time_comparison_field(specification)
|
167
|
+
if specification.time_sort_by_as_of?
|
168
|
+
"COALESCE(#{@event_klass.table_name}.valid_at, #{@event_klass.table_name}.created_at)"
|
169
|
+
else
|
170
|
+
"#{@event_klass.table_name}.created_at"
|
171
|
+
end
|
172
|
+
end
|
173
|
+
|
167
174
|
def older_than_condition(specification)
|
168
|
-
["#{
|
175
|
+
["#{time_comparison_field(specification)} < ?", specification.older_than]
|
169
176
|
end
|
170
177
|
|
171
178
|
def older_than_or_equal_condition(specification)
|
172
|
-
["#{
|
179
|
+
["#{time_comparison_field(specification)} <= ?", specification.older_than_or_equal]
|
173
180
|
end
|
174
181
|
|
175
182
|
def newer_than_condition(specification)
|
176
|
-
["#{
|
183
|
+
["#{time_comparison_field(specification)} > ?", specification.newer_than]
|
177
184
|
end
|
178
185
|
|
179
186
|
def newer_than_or_equal_condition(specification)
|
180
|
-
["#{
|
187
|
+
["#{time_comparison_field(specification)} >= ?", specification.newer_than_or_equal]
|
181
188
|
end
|
182
189
|
|
183
190
|
def order(spec)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby_event_store-active_record
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.8.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Arkency
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-01-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ruby_event_store
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - '='
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 2.
|
19
|
+
version: 2.8.1
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - '='
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 2.
|
26
|
+
version: 2.8.1
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: activerecord
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|