Skip to content

Commit 024879b

Browse files
authored
Merge pull request #2856 from stakwork/feature/engagement
feat: change endpoint for followers/engagement
2 parents 164345d + 8d214a9 commit 024879b

File tree

3 files changed

+26
-13
lines changed

3 files changed

+26
-13
lines changed

src/components/ModalsContainer/TweetAnalyze/Body/Engagement/index.tsx

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { ClipLoader } from 'react-spinners'
66
import { CsvDownloadButton } from '~/components/common/CsvDownloader'
77
import { Flex } from '~/components/common/Flex'
88
import LinkIcon from '~/components/Icons/LinkIcon'
9-
import { getPathway } from '~/network/fetchSourcesData'
9+
import { getEngagement, getFollowers } from '~/network/tweetAnalyze'
1010
import { Node } from '~/types'
1111
import { colors } from '~/utils'
1212
import { Avatar, Engagement, EngagementBar, SORT_OPTIONS, SortBy, TweetLink, TweetTime, UserInfo, Username } from '..'
@@ -32,9 +32,7 @@ export const EngagementTable = ({ sortBy, idsToAnalyze }: Props) => {
3232

3333
try {
3434
const responses = await Promise.all(
35-
idsToAnalyze.map((id) =>
36-
getPathway(id, [], ['HAS_REPLY>', 'HAS_QUOTE>', 'THREAD_NEXT>', '<POSTED'], sortBy, true, 0, 10, 800),
37-
),
35+
idsToAnalyze.map((id) => (sortBy === 'followers' ? getEngagement(id) : getFollowers(id))),
3836
)
3937

4038
const mainTweetsArray = []
@@ -256,11 +254,12 @@ export const EngagementTable = ({ sortBy, idsToAnalyze }: Props) => {
256254
<>
257255
<TableCell>
258256
{tweet.properties?.impression_percentage} %
259-
{tweet.properties?.impression_count !== undefined && tweet.properties?.impression_count && (
260-
<Engagement>
261-
<EngagementBar percentage={Number(tweet.properties?.impression_percentage)} />
262-
</Engagement>
263-
)}
257+
{tweet.properties?.impression_count !== undefined &&
258+
Boolean(tweet.properties?.impression_count) && (
259+
<Engagement>
260+
<EngagementBar percentage={Number(tweet.properties?.impression_percentage)} />
261+
</Engagement>
262+
)}
264263
</TableCell>
265264
<TableCell align="right">{Number(tweet.properties?.followers).toLocaleString()}</TableCell>
266265
</>

src/components/ModalsContainer/TweetAnalyze/Body/index.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ import { EngagementTable } from './Engagement'
77
import { RetweetsTable } from './Retweets'
88
import { SentimentTable } from './Sentiment'
99

10-
const ENGAGEMENT = 'ENGAGEMENT'
11-
const FOLLOWERS = 'FOLLOWERS'
12-
const TOP_REPOSTERS = 'TOP_REPOSTERS'
13-
const SENTIMENT = 'SENTIMENT'
10+
export const ENGAGEMENT = 'ENGAGEMENT'
11+
export const FOLLOWERS = 'FOLLOWERS'
12+
export const TOP_REPOSTERS = 'TOP_REPOSTERS'
13+
export const SENTIMENT = 'SENTIMENT'
1414

1515
const ComponentsMap: Record<string, ComponentType<{ sortBy: SortBy; idsToAnalyze: string[] }>> = {
1616
[ENGAGEMENT]: EngagementTable,

src/network/tweetAnalyze/index.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { FetchDataResponse } from '~/types'
2+
import { api } from '../api'
3+
4+
export const getEngagement = async (id: string) => {
5+
const response = await api.get<FetchDataResponse>(`/mindset/tweet/engagement/${id}`)
6+
7+
return response
8+
}
9+
10+
export const getFollowers = async (id: string) => {
11+
const response = await api.get<FetchDataResponse>(`/mindset/tweet/followers/${id}`)
12+
13+
return response
14+
}

0 commit comments

Comments
 (0)