From e9c3d4848c6b32e7dadddfeaa26d2ac88ae34196 Mon Sep 17 00:00:00 2001 From: Youssif Shaaban Alsager Date: Sun, 11 Jun 2023 10:49:17 +0000 Subject: [PATCH] fix(route): Add missing first part of rattibha threads (#12633) * fix(route): Add missing first part of rattibha threads Signed-off-by: Youssif Shaaban Alsager * fix(route): Use correct cache key for getting rattibha thread * fix(route): Cache item cottectly in rattibha thread --------- Signed-off-by: Youssif Shaaban Alsager --- lib/v2/rattibha/user.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/v2/rattibha/user.js b/lib/v2/rattibha/user.js index 8aa1dbc640..124c4a657a 100644 --- a/lib/v2/rattibha/user.js +++ b/lib/v2/rattibha/user.js @@ -21,15 +21,17 @@ module.exports = async (ctx) => { pubDate: parseDate(item.thread.created_at), updated: parseDate(item.thread.updated_at), author: userData.name, - api_link: `${baseUrl}/threads?id=${item.thread_id}`, + threadData1URL: `${baseUrl}/thread?id=${item.thread_id}`, + threadData2URL: `${baseUrl}/threads?id=${item.thread_id}`, })); // Get tweet full text const items = await Promise.all( list.map((item) => - ctx.cache.tryGet(item.api_link, async () => { - const { data: threads } = await got(item.api_link, { headers: { accept: 'application/json' } }); - item.description = threads.reduce((accumulator, tweet) => `${accumulator}${tweet.tweet_detail.info.text}
`, ''); + ctx.cache.tryGet(item.link, async () => { + const { data: data1 } = await got(item.threadData1URL, { headers: { accept: 'application/json' } }); + const { data: data2 } = await got(item.threadData2URL, { headers: { accept: 'application/json' } }); + item.description = [...data1.tweets, ...data2].reduce((accumulator, tweet) => `${accumulator}${tweet.tweet_detail.info.text}
`, ''); return item; }) )