event_store 0.2.4 → 0.2.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/lib/event_store/aggregate.rb +9 -1
- data/lib/event_store/client.rb +8 -0
- data/lib/event_store/version.rb +1 -1
- data/spec/event_store/client_spec.rb +10 -0
- data/spec/spec_helper.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
NDEyNGVmMjcwZWFkMjJkMzdkOTg5NWJiNDdlZWJjMmZlN2MzMDI3Ng==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
M2Q4YjFiZjU5M2FkNDczM2NiNjQxMGMzM2YwNjg3ZTZlYTAwZGY3Nw==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
MGNiNDRkNjk3NGZmODQ2MGVmNzE4NjM5YmIzMzQ0MjA3NjA3Mzg5ZWJhYTI1
|
10
|
+
ZjM2NjBlZDJiNWM2N2IyZjVjOWJiNGVlZThhNDI1ODc4NmQyOGE0ZjUzM2E4
|
11
|
+
Mzc2ZGY1ZWFiOTIxYTFmOWM3NjliMWViNTdiYWE2MzM5MTk4MjY=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
ZjU4NWMxMzdmNGFkMjUxNDhhODEwZWRlMTNjOTRmOGNkMGJjNGE2YTVkODIy
|
14
|
+
Y2Q0MjVhMjJhZWI3ODEyNzBkOGExMDkxNGYzODczODEwOWRhMzc2MjkzMTg0
|
15
|
+
OTQzYTRmODAxOTc4N2Y3ODIxYmJhYzA3NTlhY2YwMmJlZDNkNmU=
|
@@ -3,6 +3,14 @@ module EventStore
|
|
3
3
|
|
4
4
|
attr_reader :id, :type, :snapshot_table, :snapshot_version_table, :event_table
|
5
5
|
|
6
|
+
def self.count
|
7
|
+
EventStore.db.from( EventStore.fully_qualified_table).distinct(:aggregate_id).count
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.ids(offset, limit)
|
11
|
+
EventStore.db.from( EventStore.fully_qualified_table).distinct(:aggregate_id).select(:aggregate_id).order(:aggregate_id).limit(limit, offset).all.map{|item| item[:aggregate_id]}
|
12
|
+
end
|
13
|
+
|
6
14
|
def initialize(id, type = EventStore.table_name)
|
7
15
|
@id = id
|
8
16
|
@type = type
|
@@ -73,4 +81,4 @@ module EventStore
|
|
73
81
|
EventStore.redis.hgetall(@snapshot_table)
|
74
82
|
end
|
75
83
|
end
|
76
|
-
end
|
84
|
+
end
|
data/lib/event_store/client.rb
CHANGED
@@ -1,6 +1,14 @@
|
|
1
1
|
module EventStore
|
2
2
|
class Client
|
3
3
|
|
4
|
+
def self.count
|
5
|
+
Aggregate.count
|
6
|
+
end
|
7
|
+
|
8
|
+
def self.ids(offset, limit)
|
9
|
+
Aggregate.ids(offset, limit)
|
10
|
+
end
|
11
|
+
|
4
12
|
def initialize( aggregate_id, aggregate_type = EventStore.table_name)
|
5
13
|
@aggregate = Aggregate.new(aggregate_id, aggregate_type)
|
6
14
|
end
|
data/lib/event_store/version.rb
CHANGED
@@ -20,6 +20,16 @@ describe EventStore::Client do
|
|
20
20
|
client_2.append events_by_aggregate_id[AGGREGATE_ID_TWO]
|
21
21
|
end
|
22
22
|
|
23
|
+
it "counts the number of aggregates or clients" do
|
24
|
+
expect(es_client.count).to eql(2)
|
25
|
+
end
|
26
|
+
|
27
|
+
it "returns a partial list of aggregates" do
|
28
|
+
offset = 0
|
29
|
+
limit = 1
|
30
|
+
es_client.ids(offset, limit).should == [[AGGREGATE_ID_ONE, AGGREGATE_ID_TWO].sort.first]
|
31
|
+
end
|
32
|
+
|
23
33
|
describe '#raw_event_stream' do
|
24
34
|
it "should be an array of hashes that represent database records, not EventStore::SerializedEvent objects" do
|
25
35
|
raw_stream = es_client.new(AGGREGATE_ID_ONE, :device).raw_event_stream
|
data/spec/spec_helper.rb
CHANGED