Move parsing of tokens out of storage layer

This commit is contained in:
Erik Johnston 2019-05-16 14:24:58 +01:00
parent 2c662ddde4
commit 7a7eba8302
2 changed files with 21 additions and 14 deletions

View file

@ -54,7 +54,7 @@ class PaginationChunk(object):
return d
@attr.s
@attr.s(frozen=True, slots=True)
class RelationPaginationToken(object):
"""Pagination token for relation pagination API.
@ -85,7 +85,7 @@ class RelationPaginationToken(object):
return attr.astuple(self)
@attr.s
@attr.s(frozen=True, slots=True)
class AggregationPaginationToken(object):
"""Pagination token for relation aggregation pagination API.
@ -151,12 +151,6 @@ class RelationsWorkerStore(SQLBaseStore):
requested. The rows are of the form `{"event_id": "..."}`.
"""
if from_token:
from_token = RelationPaginationToken.from_string(from_token)
if to_token:
to_token = RelationPaginationToken.from_string(to_token)
where_clause = ["relates_to_id = ?"]
where_args = [event_id]
@ -258,12 +252,6 @@ class RelationsWorkerStore(SQLBaseStore):
match. Each row is a dict with `type`, `key` and `count` fields.
"""
if from_token:
from_token = AggregationPaginationToken.from_string(from_token)
if to_token:
to_token = AggregationPaginationToken.from_string(to_token)
where_clause = ["relates_to_id = ?", "relation_type = ?"]
where_args = [event_id, RelationTypes.ANNOTATION]