From c05187c20f9bb49912be7f9d615df4f49160d95f Mon Sep 17 00:00:00 2001 From: joec05 Date: Mon, 11 Dec 2023 21:45:31 +0700 Subject: [PATCH] update --- .gitignore | 2 ++ dist/controllers/users.js | 16 ++++++++++++++-- dist/index.js | 1 + src/index.ts | 1 - vercel.json | 15 --------------- 5 files changed, 17 insertions(+), 18 deletions(-) delete mode 100644 vercel.json diff --git a/.gitignore b/.gitignore index dbb58ff..e928cb8 100644 --- a/.gitignore +++ b/.gitignore @@ -64,3 +64,5 @@ node_modules/ # dotenv environment variables file .env + +.vercel diff --git a/dist/controllers/users.js b/dist/controllers/users.js index 96268b4..4dd2559 100644 --- a/dist/controllers/users.js +++ b/dist/controllers/users.js @@ -2280,8 +2280,20 @@ usersRoutes.get('/fetchTopData', (req, res) => __awaiter(void 0, void 0, void 0, const fetchTopUsers = yield profilesClient.query(fetchTopUsersQuery, [currentID, paginationLimit]); const usersID = fetchTopUsers.rows.map((e) => e.user_id); var getCompleteUsersData = yield getUsersListFilteredData(usersID, currentID); - const usersProfileData = [...new Set([...getCompleteUsersData.usersProfileData, ...getCompletePostsData.usersProfileData])]; - const usersSocialsData = [...new Set([...getCompleteUsersData.usersSocialsData, ...getCompletePostsData.usersSocialsData])]; + var combinedUsersID = []; + var combinedUsersProfileData = [...getCompleteUsersData.usersProfileData, ...getCompletePostsData.usersProfileData]; + var combinedUsersSocialsData = [...getCompleteUsersData.usersSocialsData, ...getCompletePostsData.usersSocialsData]; + var filteredUsersProfileData = []; + var filteredUsersSocialsData = []; + for (var i = 0; i < combinedUsersProfileData.length; i++) { + if (!combinedUsersID.includes(combinedUsersProfileData[i].user_id)) { + combinedUsersID.push(combinedUsersProfileData[i].user_id); + filteredUsersProfileData.push(combinedUsersProfileData[i]); + filteredUsersSocialsData.push(combinedUsersSocialsData[i]); + } + } + const usersProfileData = filteredUsersProfileData; + const usersSocialsData = filteredUsersSocialsData; const fetchHashtagsDataQuery = `SELECT * FROM hashtags.hashtags_list ORDER BY hashtag_count DESC OFFSET $1 LIMIT $2`; const fetchHashtagsData = yield keywordsClient.query(fetchHashtagsDataQuery, [0, paginationLimit]); const hashtagsData = fetchHashtagsData.rows; diff --git a/dist/index.js b/dist/index.js index 8cc72e9..8c6edc8 100644 --- a/dist/index.js +++ b/dist/index.js @@ -106,3 +106,4 @@ app.get('/', (req, res) => { }); app.use('/users', usersRoutes); httpServer.listen(port, () => console.log(`Server running on port: http://localhost:${port}`)); +module.exports = app; diff --git a/src/index.ts b/src/index.ts index 655150f..1cef232 100644 --- a/src/index.ts +++ b/src/index.ts @@ -131,4 +131,3 @@ app.use('/users', usersRoutes); httpServer.listen(port, () => console.log(`Server running on port: http://localhost:${port}`)); - diff --git a/vercel.json b/vercel.json deleted file mode 100644 index 8c50b02..0000000 --- a/vercel.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "version": 2, - "builds": [ - { - "src": "index.js", - "use": "@vercel/node" - } - ], - "routes": [ - { - "src": "/(.*)", - "dest": "index.js" - } - ] -} \ No newline at end of file