feat: add list_bounties and list_all_bounties methods to storage adapter
Add filtering methods to JsonFileRoomStorage for Phase 2 soft delete support: - list_bounties(room_id): returns only non-deleted bounties for normal queries - list_all_bounties(room_id, include_deleted=True): returns all bounties for /recover Update RoomStorage protocol to include the new methods. Update mock classes in tests to pass isinstance checks. Fixes #42
This commit is contained in:
@@ -48,6 +48,20 @@ class SimpleRoomStorage:
|
||||
return b
|
||||
return None
|
||||
|
||||
def list_bounties(self, room_id: int) -> list[Bounty]:
|
||||
if room_id not in self._rooms:
|
||||
return []
|
||||
return [b for b in self._rooms[room_id].bounties if b.deleted_at is None]
|
||||
|
||||
def list_all_bounties(
|
||||
self, room_id: int, include_deleted: bool = True
|
||||
) -> list[Bounty]:
|
||||
if room_id not in self._rooms:
|
||||
return []
|
||||
if include_deleted:
|
||||
return self._rooms[room_id].bounties
|
||||
return [b for b in self._rooms[room_id].bounties if b.deleted_at is None]
|
||||
|
||||
|
||||
class SimpleTrackingStorage:
|
||||
"""Minimal mock without ensure_tracking - tests if track_bounty works without it.
|
||||
@@ -119,6 +133,20 @@ class MockRoomStorage:
|
||||
return b
|
||||
return None
|
||||
|
||||
def list_bounties(self, room_id: int) -> list[Bounty]:
|
||||
if room_id not in self._rooms:
|
||||
return []
|
||||
return [b for b in self._rooms[room_id].bounties if b.deleted_at is None]
|
||||
|
||||
def list_all_bounties(
|
||||
self, room_id: int, include_deleted: bool = True
|
||||
) -> list[Bounty]:
|
||||
if room_id not in self._rooms:
|
||||
return []
|
||||
if include_deleted:
|
||||
return self._rooms[room_id].bounties
|
||||
return [b for b in self._rooms[room_id].bounties if b.deleted_at is None]
|
||||
|
||||
|
||||
class MockTrackingStorage:
|
||||
"""Mock implementation of TrackingStorage for testing."""
|
||||
|
||||
Reference in New Issue
Block a user