ruby_event_store-rom 2.1.0 → 2.2.0
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0346bda57c2f37b5dd9f545f51d980fef10af52630613aa4741f48aa57d3e8eb
|
4
|
+
data.tar.gz: 2e451dd750e028ee9f8a3182e65721c7e3c569a1ac283f9e25cb66e92ac89fac
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b4f057692be3234140fdc0102cc66af4280e1a9b83ecaff362d6a18c644fd7df5ed089dd85e3f62d10ee871d5c41fc1a1660cc96aff08d81f728554c65563070
|
7
|
+
data.tar.gz: 3eda5e842ca678da3039b04458f910021ba5639c286c8d5c0eee9c4ccfa2a10d4da3f2c4d534e7e6e65f3dd94d5e26385353b63eba36953b4bcf507e18af9785
|
@@ -34,20 +34,36 @@ module RubyEventStore
|
|
34
34
|
where(event_type: types)
|
35
35
|
end
|
36
36
|
|
37
|
-
def newer_than(time)
|
38
|
-
|
37
|
+
def newer_than(time, time_sort_by)
|
38
|
+
if time_sort_by == :as_of
|
39
|
+
where { |r| string::coalesce(r.events[:valid_at], r.events[:created_at]) > time.localtime }
|
40
|
+
else
|
41
|
+
where { |r| r.events[:created_at] > time.localtime }
|
42
|
+
end
|
39
43
|
end
|
40
44
|
|
41
|
-
def newer_than_or_equal(time)
|
42
|
-
|
45
|
+
def newer_than_or_equal(time, time_sort_by)
|
46
|
+
if time_sort_by == :as_of
|
47
|
+
where { |r| string::coalesce(r.events[:valid_at], r.events[:created_at]) >= time.localtime }
|
48
|
+
else
|
49
|
+
where { |r| r.events[:created_at] >= time.localtime }
|
50
|
+
end
|
43
51
|
end
|
44
52
|
|
45
|
-
def older_than(time)
|
46
|
-
|
53
|
+
def older_than(time, time_sort_by)
|
54
|
+
if time_sort_by == :as_of
|
55
|
+
where { |r| string::coalesce(r.events[:valid_at], r.events[:created_at]) < time.localtime }
|
56
|
+
else
|
57
|
+
where { |r| r.events[:created_at] < time.localtime }
|
58
|
+
end
|
47
59
|
end
|
48
60
|
|
49
|
-
def older_than_or_equal(time)
|
50
|
-
|
61
|
+
def older_than_or_equal(time, time_sort_by)
|
62
|
+
if time_sort_by == :as_of
|
63
|
+
where { |r| string::coalesce(r.events[:valid_at], r.events[:created_at]) <= time.localtime }
|
64
|
+
else
|
65
|
+
where { |r| r.events[:created_at] <= time.localtime }
|
66
|
+
end
|
51
67
|
end
|
52
68
|
|
53
69
|
DIRECTION_MAP = { forward: %i[asc > <], backward: %i[desc < >] }.freeze
|
@@ -23,7 +23,7 @@ module RubyEventStore
|
|
23
23
|
end
|
24
24
|
|
25
25
|
def by_event_type(types)
|
26
|
-
|
26
|
+
join_events.where(event_type: types)
|
27
27
|
end
|
28
28
|
|
29
29
|
def by_stream_and_event_id(stream, event_id)
|
@@ -34,20 +34,36 @@ module RubyEventStore
|
|
34
34
|
by_stream(stream).select(:position).order(Sequel.desc(:position)).first
|
35
35
|
end
|
36
36
|
|
37
|
-
def newer_than(time)
|
38
|
-
|
37
|
+
def newer_than(time, time_sort_by)
|
38
|
+
if time_sort_by == :as_of
|
39
|
+
join_events.where { |r| string::coalesce(r.events[:valid_at], r.events[:created_at]) > time.localtime }
|
40
|
+
else
|
41
|
+
join_events.where { |r| r.events[:created_at] > time.localtime }
|
42
|
+
end
|
39
43
|
end
|
40
44
|
|
41
|
-
def newer_than_or_equal(time)
|
42
|
-
|
45
|
+
def newer_than_or_equal(time, time_sort_by)
|
46
|
+
if time_sort_by == :as_of
|
47
|
+
join_events.where { |r| string::coalesce(r.events[:valid_at], r.events[:created_at]) >= time.localtime }
|
48
|
+
else
|
49
|
+
join_events.where { |r| r.events[:created_at] >= time.localtime }
|
50
|
+
end
|
43
51
|
end
|
44
52
|
|
45
|
-
def older_than(time)
|
46
|
-
|
53
|
+
def older_than(time, time_sort_by)
|
54
|
+
if time_sort_by == :as_of
|
55
|
+
join_events.where { |r| string::coalesce(r.events[:valid_at], r.events[:created_at]) < time.localtime }
|
56
|
+
else
|
57
|
+
join_events.where { |r| r.events[:created_at] < time.localtime }
|
58
|
+
end
|
47
59
|
end
|
48
60
|
|
49
|
-
def older_than_or_equal(time)
|
50
|
-
|
61
|
+
def older_than_or_equal(time, time_sort_by)
|
62
|
+
if time_sort_by == :as_of
|
63
|
+
join_events.where { |r| string::coalesce(r.events[:valid_at], r.events[:created_at]) <= time.localtime }
|
64
|
+
else
|
65
|
+
join_events.where { |r| r.events[:created_at] <= time.localtime }
|
66
|
+
end
|
51
67
|
end
|
52
68
|
|
53
69
|
DIRECTION_MAP = { forward: %i[asc > <], backward: %i[desc < >] }.freeze
|
@@ -74,7 +90,15 @@ module RubyEventStore
|
|
74
90
|
if event_order_columns.empty?
|
75
91
|
query.order { |r| stream_order_columns.map { |c| r[:stream_entries][c].public_send(order) } }
|
76
92
|
else
|
77
|
-
query.
|
93
|
+
query.join_events.order { |r| event_order_columns.map { |c| r.events[c].public_send(order) } }
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
def join_events
|
98
|
+
if dataset.opts[:join]&.map(&:table)&.include?(events.dataset.first_source_table)
|
99
|
+
self
|
100
|
+
else
|
101
|
+
join(:events)
|
78
102
|
end
|
79
103
|
end
|
80
104
|
end
|
@@ -65,6 +65,20 @@ module RubyEventStore
|
|
65
65
|
|
66
66
|
protected
|
67
67
|
|
68
|
+
def find_event_id_in_stream(specification_event_id, specification_stream_name)
|
69
|
+
stream_entries
|
70
|
+
.by_stream_and_event_id(specification_stream_name, specification_event_id)
|
71
|
+
.fetch(:id)
|
72
|
+
rescue ::ROM::TupleCountMismatchError
|
73
|
+
raise EventNotFound.new(specification_event_id)
|
74
|
+
end
|
75
|
+
|
76
|
+
def find_event_id_globally(specification_event_id)
|
77
|
+
events.by_event_id(specification_event_id).one!.fetch(:id)
|
78
|
+
rescue ::ROM::TupleCountMismatchError
|
79
|
+
raise EventNotFound.new(specification_event_id)
|
80
|
+
end
|
81
|
+
|
68
82
|
def read_scope(specification)
|
69
83
|
direction = specification.forward? ? :forward : :backward
|
70
84
|
|
@@ -73,20 +87,14 @@ module RubyEventStore
|
|
73
87
|
end
|
74
88
|
|
75
89
|
if specification.stream.global?
|
76
|
-
offset_entry_id =
|
77
|
-
stop_entry_id =
|
90
|
+
offset_entry_id = find_event_id_globally(specification.start) if specification.start
|
91
|
+
stop_entry_id = find_event_id_globally(specification.stop) if specification.stop
|
78
92
|
|
79
93
|
query = events.ordered(direction, offset_entry_id, stop_entry_id, specification.time_sort_by)
|
80
94
|
query = query.map_with(:event_to_serialized_record, auto_struct: false)
|
81
95
|
else
|
82
|
-
offset_entry_id =
|
83
|
-
|
84
|
-
.by_stream_and_event_id(specification.stream, specification.start)
|
85
|
-
.fetch(:id) if specification.start
|
86
|
-
stop_entry_id =
|
87
|
-
stream_entries
|
88
|
-
.by_stream_and_event_id(specification.stream, specification.stop)
|
89
|
-
.fetch(:id) if specification.stop
|
96
|
+
offset_entry_id = find_event_id_in_stream(specification.start, specification.stream) if specification.start
|
97
|
+
stop_entry_id = find_event_id_in_stream(specification.stop, specification.stream) if specification.stop
|
90
98
|
|
91
99
|
query =
|
92
100
|
stream_entries.ordered(
|
@@ -102,10 +110,10 @@ module RubyEventStore
|
|
102
110
|
|
103
111
|
query = query.by_event_id(specification.with_ids) if specification.with_ids
|
104
112
|
query = query.by_event_type(specification.with_types) if specification.with_types?
|
105
|
-
query = query.older_than(specification.older_than) if specification.older_than
|
106
|
-
query = query.older_than_or_equal(specification.older_than_or_equal) if specification.older_than_or_equal
|
107
|
-
query = query.newer_than(specification.newer_than) if specification.newer_than
|
108
|
-
query = query.newer_than_or_equal(specification.newer_than_or_equal) if specification.newer_than_or_equal
|
113
|
+
query = query.older_than(specification.older_than, specification.time_sort_by) if specification.older_than
|
114
|
+
query = query.older_than_or_equal(specification.older_than_or_equal, specification.time_sort_by) if specification.older_than_or_equal
|
115
|
+
query = query.newer_than(specification.newer_than, specification.time_sort_by) if specification.newer_than
|
116
|
+
query = query.newer_than_or_equal(specification.newer_than_or_equal, specification.time_sort_by) if specification.newer_than_or_equal
|
109
117
|
query
|
110
118
|
end
|
111
119
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby_event_store-rom
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joel Van Horn
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-09-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dry-container
|
@@ -171,14 +171,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
171
171
|
requirements:
|
172
172
|
- - ">="
|
173
173
|
- !ruby/object:Gem::Version
|
174
|
-
version: '2.
|
174
|
+
version: '2.7'
|
175
175
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
176
176
|
requirements:
|
177
177
|
- - ">="
|
178
178
|
- !ruby/object:Gem::Version
|
179
179
|
version: '0'
|
180
180
|
requirements: []
|
181
|
-
rubygems_version: 3.4.
|
181
|
+
rubygems_version: 3.4.17
|
182
182
|
signing_key:
|
183
183
|
specification_version: 4
|
184
184
|
summary: ROM events repository for Ruby Event Store
|