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 CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- M2I1NmJmY2VlYTY1ODA3YmNmMjgzZmIxOTRiZDNlMDBhZTUxY2Y4YQ==
4
+ NDEyNGVmMjcwZWFkMjJkMzdkOTg5NWJiNDdlZWJjMmZlN2MzMDI3Ng==
5
5
  data.tar.gz: !binary |-
6
- OGMzMjM5ZmJjZjQxZjM0NWNhYjFiNWY5YjZkYTZkOGNiY2RmMTlhOA==
6
+ M2Q4YjFiZjU5M2FkNDczM2NiNjQxMGMzM2YwNjg3ZTZlYTAwZGY3Nw==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- ZDc0NjVmYjJkYmM5OWRkNWUxMTA4MDJmYTQ3NWUxMzM2ZTk5MTA0NWE5NTVk
10
- MzI5MzZhNDMwZjg1NzI3Mjc3NmZlOTdiMDVkZTNlYmE4NjJiMzc5ZDE5MDZk
11
- OGM1ZmNjOThhNDliMTdlZWIyZjI3MmIzY2QwNjMwZjI5ZGIwNGM=
9
+ MGNiNDRkNjk3NGZmODQ2MGVmNzE4NjM5YmIzMzQ0MjA3NjA3Mzg5ZWJhYTI1
10
+ ZjM2NjBlZDJiNWM2N2IyZjVjOWJiNGVlZThhNDI1ODc4NmQyOGE0ZjUzM2E4
11
+ Mzc2ZGY1ZWFiOTIxYTFmOWM3NjliMWViNTdiYWE2MzM5MTk4MjY=
12
12
  data.tar.gz: !binary |-
13
- NjRlOGE3ZWEyZTA2OWEwYjEzN2ZlMzZkYjg5MWY2YjI4NDE0ZDgwMDZiMTZi
14
- NzljMWY4YWU2MTMxNzk2ZDMyNzYyYThkOTc2ZjQwMjcxZWRiZDA5ZjUyMGRj
15
- NDZhYWJiNjU3NjhjMjI0ZjdiM2NiOWQ5NjkyZGNmMzFmOGY0OTU=
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
@@ -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
@@ -1,3 +1,3 @@
1
1
  module EventStore
2
- VERSION = "0.2.4"
2
+ VERSION = "0.2.5"
3
3
  end
@@ -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
@@ -25,4 +25,4 @@ RSpec.configure do |config|
25
25
  config.after(:each) do
26
26
  EventStore.clear!
27
27
  end
28
- end
28
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: event_store
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.4
4
+ version: 0.2.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Paul Saieg, John Colvin