From 6a6a002e7492394cf6b2f6d231667b164cf41d06 Mon Sep 17 00:00:00 2001 From: jasta Date: Sat, 17 Aug 2024 18:42:37 +0900 Subject: [PATCH] add links of tweets --- api/birdxplorer_api/routers/data.py | 4 ++++ common/birdxplorer_common/models.py | 1 + 2 files changed, 5 insertions(+) diff --git a/api/birdxplorer_api/routers/data.py b/api/birdxplorer_api/routers/data.py index 418cbd6..2959dbc 100644 --- a/api/birdxplorer_api/routers/data.py +++ b/api/birdxplorer_api/routers/data.py @@ -123,6 +123,10 @@ def get_posts( 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