From b045ec1c280400dea43ec41c81199c1ce5dffe19 Mon Sep 17 00:00:00 2001 From: osoken Date: Sun, 18 Aug 2024 12:11:58 +0900 Subject: [PATCH] feat: add get_number_of_posts method to the storage class --- api/birdxplorer_api/routers/data.py | 4 +--- common/birdxplorer_common/storage.py | 10 ++++++++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/api/birdxplorer_api/routers/data.py b/api/birdxplorer_api/routers/data.py index 2ef6145..ad22488 100644 --- a/api/birdxplorer_api/routers/data.py +++ b/api/birdxplorer_api/routers/data.py @@ -125,9 +125,7 @@ def get_posts( search_text=search_text, ) - total_count = len(posts) - paginated_posts = posts[offset : offset + limit] - for post in paginated_posts: + for post in posts: post.link = HttpUrl(f"https://x.com/{post.x_user.name}/status/{post.post_id}") base_url = str(request.url).split("?")[0] diff --git a/common/birdxplorer_common/storage.py b/common/birdxplorer_common/storage.py index e318459..b98f026 100644 --- a/common/birdxplorer_common/storage.py +++ b/common/birdxplorer_common/storage.py @@ -322,6 +322,16 @@ def get_number_of_posts( query = query.filter(PostRecord.text.like(f"%{search_text}%")) return query.count() + def get_number_of_posts( + self, + post_ids: Union[List[PostId], None] = None, + note_ids: Union[List[NoteId], None] = None, + start: Union[TwitterTimestamp, None] = None, + end: Union[TwitterTimestamp, None] = None, + search_text: Union[str, None] = None, + ) -> int: + raise NotImplementedError + def gen_storage(settings: GlobalSettings) -> Storage: engine = create_engine(settings.storage_settings.sqlalchemy_database_url)