Skip to content

Commit 26908af

Browse files
author
Felipe Nunes
committed
fix: implementar find_paginated_records em InMemoryStorage
Adiciona implementação do método find_paginated_records na classe InMemoryStorage para corrigir erro de classe abstrata. O método foi declarado como abstrato em BaseStorage mas não foi implementado em InMemoryStorage, causando TypeError nos testes. Também atualiza assinaturas de find_all_records para incluir parâmetros order_by e descending para consistência com BaseStorage.
1 parent 8639598 commit 26908af

File tree

1 file changed

+36
-3
lines changed

1 file changed

+36
-3
lines changed

aries_cloudagent/storage/in_memory.py

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"""Basic in-memory storage implementation (non-wallet)."""
22

3-
from typing import Mapping, Sequence
3+
from typing import Mapping, Optional, Sequence
44

55
from ..core.in_memory import InMemoryProfile
66

@@ -105,8 +105,10 @@ async def delete_record(self, record: StorageRecord):
105105
async def find_all_records(
106106
self,
107107
type_filter: str,
108-
tag_query: Mapping = None,
109-
options: Mapping = None,
108+
tag_query: Optional[Mapping] = None,
109+
order_by: Optional[str] = None,
110+
descending: bool = False,
111+
options: Optional[Mapping] = None,
110112
):
111113
"""Retrieve all records matching a particular type filter and tag query."""
112114
results = []
@@ -115,6 +117,37 @@ async def find_all_records(
115117
results.append(record)
116118
return results
117119

120+
async def find_paginated_records(
121+
self,
122+
type_filter: str,
123+
tag_query: Optional[Mapping] = None,
124+
limit: int = DEFAULT_PAGE_SIZE,
125+
offset: int = 0,
126+
order_by: Optional[str] = None,
127+
descending: bool = False,
128+
) -> Sequence[StorageRecord]:
129+
"""Retrieve a page of records matching a particular type filter and tag query.
130+
131+
Args:
132+
type_filter: The type of records to filter by
133+
tag_query: An optional dictionary of tag filter clauses
134+
limit: The maximum number of records to retrieve
135+
offset: The offset to start retrieving records from
136+
order_by: An optional field by which to order the records (not supported in InMemoryStorage)
137+
descending: Whether to order the records in descending order (not supported in InMemoryStorage)
138+
139+
Returns:
140+
A sequence of StorageRecord matching the filter and query parameters
141+
"""
142+
# Get all matching records
143+
results = []
144+
for record in self.profile.records.values():
145+
if record.type == type_filter and tag_query_match(record.tags, tag_query):
146+
results.append(record)
147+
148+
# Apply pagination
149+
return results[offset:offset + limit]
150+
118151
async def delete_all_records(
119152
self,
120153
type_filter: str,

0 commit comments

Comments
 (0)