Skip to content

Commit

Permalink
feat: add get_number_of_posts method to the storage class
Browse files Browse the repository at this point in the history
  • Loading branch information
osoken committed Aug 18, 2024
1 parent 75c4be4 commit b045ec1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
4 changes: 1 addition & 3 deletions api/birdxplorer_api/routers/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
10 changes: 10 additions & 0 deletions common/birdxplorer_common/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit b045ec1

Please sign in to comment.