Skip to content
This repository was archived by the owner on Aug 15, 2023. It is now read-only.

Commit 74cf4ed

Browse files
committed
fix(ycai): return total contributions in get creator stats api (#358)
1 parent c196c65 commit 74cf4ed

File tree

5 files changed

+12
-14
lines changed

5 files changed

+12
-14
lines changed

YCAI/src/components/dashboard/community/AnalyticsPage.tsx

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ const CreatorAnalyticsPage: React.FC<CreatorAnalyticsPageProps> = ({
7070
const theme = useTheme();
7171
const { t } = useTranslation();
7272

73-
const amount = 20;
73+
const amount = 25;
7474
return (
7575
<Grid item md={12}>
7676
{profile === undefined ? (
@@ -80,11 +80,6 @@ const CreatorAnalyticsPage: React.FC<CreatorAnalyticsPageProps> = ({
8080
queries={{ stats: ccRelatedUsers }}
8181
params={{ stats: { params: { amount, skip: 0 } } }}
8282
render={QR.fold(LazyFullSizeLoader, ErrorBox, ({ stats }) => {
83-
const recommendationsAnalyzed = stats.content.reduce(
84-
(acc, c) => acc + c.recommendedChannelCount,
85-
0
86-
);
87-
8883
return (
8984
<Grid container spacing={2}>
9085
<Grid item md={3} sm={6}>
@@ -100,13 +95,13 @@ const CreatorAnalyticsPage: React.FC<CreatorAnalyticsPageProps> = ({
10095
<Grid item sm={12}>
10196
<StatsCard
10297
header={t('analytics:total_recommendations')}
103-
count={recommendationsAnalyzed}
98+
count={stats.totalRecommendations}
10499
/>
105100
</Grid>
106101
<Grid item sm={12}>
107102
<StatsCard
108-
header={t('analytics:total_metadata')}
109-
count={stats.totalRecommendations}
103+
header={t('analytics:total_contributions')}
104+
count={stats.totalContributions}
110105
color={theme.palette.primary.main}
111106
/>
112107
</Grid>

YCAI/src/i18n/en-US.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ const resources: CustomTypeOptions['resources'] = {
133133
recommendations_title: 'Recommendations Analyzed',
134134
recommendations_for_other_channels: 'From other channels',
135135
total_recommendations: 'Total recommendations',
136-
total_metadata: 'Total metadata',
136+
total_contributions: 'Total Contributions',
137137
notifications_title: 'Notifications',
138138
top_n_cc_related_to_your_channel:
139139
'Most recommended channels on your videos:',

YCAI/typings/react-i18next/index.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ declare module 'react-i18next' {
114114
recommendations_title: string;
115115
recommendations_for_other_channels: string;
116116
total_recommendations: string;
117-
total_metadata: string;
117+
total_contributions: string;
118118
notifications_title: string;
119119
top_n_cc_related_to_your_channel: string;
120120
advertising_connected_to_your_videos_title: string;
@@ -170,7 +170,7 @@ declare module 'react-i18next' {
170170
swagger: {
171171
title: string;
172172
description: string;
173-
}
173+
};
174174
};
175175
}
176176
}

backend/lib/automo.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ async function getMetadataFromAuthorChannelId(channelId, options) {
252252
cappedResultsOpts
253253
);
254254

255-
const totalRelatedCount = [
255+
const totalRelatedCountFilters = [
256256
{
257257
$match: filter,
258258
},
@@ -263,7 +263,7 @@ async function getMetadataFromAuthorChannelId(channelId, options) {
263263
const [relatedTotal] = await mongo3.aggregate(
264264
mongoc,
265265
nconf.get('schema').metadata,
266-
totalRelatedCount
266+
totalRelatedCountFilters
267267
);
268268

269269
const [totalRecommendedSource] = await mongo3.aggregate(
@@ -287,6 +287,7 @@ async function getMetadataFromAuthorChannelId(channelId, options) {
287287
channelId,
288288
authorName: null,
289289
totalRecommendations: totalRecommendedSource?.total ?? 0,
290+
totalContributions: relatedTotal?.total ?? 0,
290291
score: 0,
291292
pagination: options,
292293
content: [],
@@ -311,6 +312,7 @@ async function getMetadataFromAuthorChannelId(channelId, options) {
311312
channelId,
312313
authorName,
313314
totalRecommendations: totalRecommendedSource.total,
315+
totalContributions: relatedTotal.total,
314316
score,
315317
pagination: options,
316318
content,

packages/shared/src/models/ChannelRelated.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ export const GetRelatedChannelsOutput = t.strict(
1818
authorName: t.union([t.null, t.string]),
1919
score: t.number,
2020
totalRecommendations: t.number,
21+
totalContributions: t.number,
2122
pagination: t.strict({
2223
amount: t.number,
2324
}),

0 commit comments

Comments
 (0)