diff --git a/api/birdxplorer_api/routers/data.py b/api/birdxplorer_api/routers/data.py index ad22488..75ed648 100644 --- a/api/birdxplorer_api/routers/data.py +++ b/api/birdxplorer_api/routers/data.py @@ -96,22 +96,22 @@ def get_posts( request: Request, post_id: Union[List[PostId], None] = Query(default=None), note_id: Union[List[NoteId], None] = Query(default=None), - created_at_start: Union[None, TwitterTimestamp, str] = Query(default=None), - created_at_end: Union[None, TwitterTimestamp, str] = Query(default=None), + created_at_from: Union[None, TwitterTimestamp, str] = Query(default=None), + created_at_to: Union[None, TwitterTimestamp, str] = Query(default=None), offset: int = Query(default=0, ge=0), limit: int = Query(default=100, gt=0, le=1000), search_text: Union[None, str] = Query(default=None), ) -> PostListResponse: - if created_at_start is not None and isinstance(created_at_start, str): - created_at_start = ensure_twitter_timestamp(created_at_start) - if created_at_end is not None and isinstance(created_at_end, str): - created_at_end = ensure_twitter_timestamp(created_at_end) + if created_at_from is not None and isinstance(created_at_from, str): + created_at_from = ensure_twitter_timestamp(created_at_from) + if created_at_to is not None and isinstance(created_at_to, str): + created_at_to = ensure_twitter_timestamp(created_at_to) posts = list( storage.get_posts( post_ids=post_id, note_ids=note_id, - start=created_at_start, - end=created_at_end, + start=created_at_from, + end=created_at_to, search_text=search_text, offset=offset, limit=limit, @@ -120,8 +120,8 @@ def get_posts( total_count = storage.get_number_of_posts( post_ids=post_id, note_ids=note_id, - start=created_at_start, - end=created_at_end, + start=created_at_from, + end=created_at_to, search_text=search_text, ) diff --git a/api/tests/routers/test_data.py b/api/tests/routers/test_data.py index baec52b..67160f9 100644 --- a/api/tests/routers/test_data.py +++ b/api/tests/routers/test_data.py @@ -61,14 +61,14 @@ def test_posts_get_has_note_id_filter(client: TestClient, post_samples: List[Pos def test_posts_get_has_created_at_filter_start_and_end(client: TestClient, post_samples: List[Post]) -> None: - response = client.get("/api/v1/data/posts/?createdAtStart=2006-7-25 00:00:00&createdAtEnd=2006-7-30 23:59:59") + response = client.get("/api/v1/data/posts/?createdAtFrom=2006-7-25 00:00:00&createdAtTo=2006-7-30 23:59:59") assert response.status_code == 200 res_json = response.json() assert res_json == {"data": [json.loads(post_samples[1].model_dump_json())], "meta": {"next": None, "prev": None}} def test_posts_get_has_created_at_filter_start(client: TestClient, post_samples: List[Post]) -> None: - response = client.get("/api/v1/data/posts/?createdAtStart=2006-7-25 00:00:00") + response = client.get("/api/v1/data/posts/?createdAtFrom=2006-7-25 00:00:00") assert response.status_code == 200 res_json = response.json() assert res_json == { @@ -78,7 +78,7 @@ def test_posts_get_has_created_at_filter_start(client: TestClient, post_samples: def test_posts_get_has_created_at_filter_end(client: TestClient, post_samples: List[Post]) -> None: - response = client.get("/api/v1/data/posts/?createdAtEnd=2006-7-30 00:00:00") + response = client.get("/api/v1/data/posts/?createdAtTo=2006-7-30 00:00:00") assert response.status_code == 200 res_json = response.json() assert res_json == { @@ -88,14 +88,14 @@ def test_posts_get_has_created_at_filter_end(client: TestClient, post_samples: L def test_posts_get_created_at_range_filter_accepts_integer(client: TestClient, post_samples: List[Post]) -> None: - response = client.get("/api/v1/data/posts/?createdAtStart=1153921700000&createdAtEnd=1154921800000") + response = client.get("/api/v1/data/posts/?createdAtFrom=1153921700000&createdAtTo=1154921800000") assert response.status_code == 200 res_json = response.json() assert res_json == {"data": [json.loads(post_samples[1].model_dump_json())], "meta": {"next": None, "prev": None}} def test_posts_get_created_at_start_filter_accepts_integer(client: TestClient, post_samples: List[Post]) -> None: - response = client.get("/api/v1/data/posts/?createdAtStart=1153921700000") + response = client.get("/api/v1/data/posts/?createdAtFrom=1153921700000") assert response.status_code == 200 res_json = response.json() assert res_json == { @@ -105,7 +105,7 @@ def test_posts_get_created_at_start_filter_accepts_integer(client: TestClient, p def test_posts_get_created_at_end_filter_accepts_integer(client: TestClient, post_samples: List[Post]) -> None: - response = client.get("/api/v1/data/posts/?createdAtEnd=1154921800000") + response = client.get("/api/v1/data/posts/?createdAtTo=1154921800000") assert response.status_code == 200 res_json = response.json() assert res_json == { @@ -115,7 +115,7 @@ def test_posts_get_created_at_end_filter_accepts_integer(client: TestClient, pos def test_posts_get_timestamp_out_of_range(client: TestClient, post_samples: List[Post]) -> None: - response = client.get("/api/v1/data/posts/?createdAtStart=1153921700&createdAtEnd=1153921700") + response = client.get("/api/v1/data/posts/?createdAtFrom=1153921700&createdAtTo=1153921700") assert response.status_code == 422