Skip to content

Commit

Permalink
Removed (presently unused) "resume" token.
Browse files Browse the repository at this point in the history
To be reintroduced...
  • Loading branch information
johnbywater committed Dec 8, 2017
1 parent 27cbb8e commit da32a6b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
2 changes: 1 addition & 1 deletion eventsourcing/infrastructure/activerecord.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def all_items(self):
"""

@abstractmethod
def all_records(self, resume=None, *arg, **kwargs):
def all_records(self, *arg, **kwargs):
"""
Returns all records in the table (possibly in chronological order, depending on database).
"""
Expand Down
17 changes: 10 additions & 7 deletions eventsourcing/infrastructure/cassandra/activerecords.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,9 @@ def all_items(self):
sequenced_item = self.from_active_record(record)
yield sequenced_item

def all_records(self, resume=None, *args, **kwargs):
def all_records(self, *args, **kwargs):
position_field_name = self.field_names.position
for sequence_id in self.all_sequence_ids(resume=resume):
for sequence_id in self.all_sequence_ids():
kwargs = {self.field_names.sequence_id: sequence_id}
record_query = self.filter(**kwargs).limit(100).order_by(position_field_name)
record_page = list(record_query)
Expand All @@ -97,12 +97,15 @@ def all_records(self, resume=None, *args, **kwargs):
kwargs = {'{}__gt'.format(position_field_name): getattr(last_record, position_field_name)}
record_page = list(record_query.filter(**kwargs))

def all_sequence_ids(self, resume=None):
def all_sequence_ids(self):
query = self.active_record_class.objects.all().limit(1)
if resume is None:
page = list(query)
else:
page = list(query.filter(pk__token__gt=Token(resume)))

# Todo: If there were a resume token, it could be used like this:
# if resume is None:
# page = list(query)
# else:
# page = list(query.filter(pk__token__gt=Token(resume)))
page = list(query)

while page:
for record in page:
Expand Down
2 changes: 1 addition & 1 deletion eventsourcing/infrastructure/sqlalchemy/activerecords.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ def from_active_record(self, active_record):
kwargs = self.get_field_kwargs(active_record)
return self.sequenced_item_class(**kwargs)

def all_records(self, resume=None, *args, **kwargs):
def all_records(self, *args, **kwargs):
"""
Returns all records in the table.
"""
Expand Down

0 comments on commit da32a6b

Please sign in to comment.