Skip to content

Commit 0067b93

Browse files
committed
Fix: reactivate message API time filters (#345)
Problem: the time filters are ignored in the messages.json endpoint since #337. Solution: reactivate the filtering.
1 parent f9eb9ff commit 0067b93

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

src/aleph/web/controllers/messages.py

+10
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
LIST_FIELD_SEPARATOR,
1515
Pagination,
1616
cond_output,
17+
make_date_filters,
1718
)
1819

1920
LOGGER = logging.getLogger(__name__)
@@ -175,6 +176,15 @@ class MessageQueryParams(BaseMessageQueryParams):
175176
"a time field lower than this value will be returned.",
176177
)
177178

179+
def to_filter_list(self) -> List[Mapping[str, Any]]:
180+
filters = super().to_filter_list()
181+
date_filters = make_date_filters(
182+
start=self.start_date, end=self.end_date, filter_key="time"
183+
)
184+
if date_filters:
185+
filters.append(date_filters)
186+
return filters
187+
178188

179189
class WsMessageQueryParams(BaseMessageQueryParams):
180190
history: Optional[int] = Field(

tests/api/test_messages.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ async def fetch_messages_filter_time_expect_success(
171171
@pytest.mark.asyncio
172172
async def test_time_filters(fixture_messages, ccn_api_client):
173173
# Start and end time specified, should return all messages
174-
start_time, end_time = 164821580, 1648215820
174+
start_time, end_time = 1648215900, 1652126600
175175
messages = await fetch_messages_filter_time_expect_success(
176176
ccn_api_client, start=start_time, end=end_time
177177
)

0 commit comments

Comments
 (0)