From a34b9694b804e9fc1ae157f3c15b3e710d6ece2e Mon Sep 17 00:00:00 2001 From: osoken Date: Sun, 18 Aug 2024 12:09:14 +0900 Subject: [PATCH] add links of tweets --- api/birdxplorer_api/routers/data.py | 5 +++++ common/birdxplorer_common/models.py | 1 + 2 files changed, 6 insertions(+) diff --git a/api/birdxplorer_api/routers/data.py b/api/birdxplorer_api/routers/data.py index 57d216e..4900401 100644 --- a/api/birdxplorer_api/routers/data.py +++ b/api/birdxplorer_api/routers/data.py @@ -124,6 +124,11 @@ def get_posts( search_text=search_text, ) + total_count = len(posts) + paginated_posts = posts[offset : offset + limit] + for post in paginated_posts: + post.link = f"https://x.com/{post.x_user.name}/status/{post.post_id}" + base_url = str(request.url).split("?")[0] next_offset = offset + limit prev_offset = max(offset - limit, 0) diff --git a/common/birdxplorer_common/models.py b/common/birdxplorer_common/models.py index 7e3ab8e..5b74fdd 100644 --- a/common/birdxplorer_common/models.py +++ b/common/birdxplorer_common/models.py @@ -678,6 +678,7 @@ class XUser(BaseModel): class Post(BaseModel): + link: HttpUrl post_id: PostId x_user_id: UserId x_user: XUser