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

fix(ycai): return total contributions in get creator stats api #358

Merged
merged 2 commits into from
Feb 3, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 4 additions & 9 deletions YCAI/src/components/dashboard/community/AnalyticsPage.tsx
Original file line number Diff line number Diff line change
@@ -70,7 +70,7 @@ const CreatorAnalyticsPage: React.FC<CreatorAnalyticsPageProps> = ({
const theme = useTheme();
const { t } = useTranslation();

const amount = 20;
const amount = 25;
return (
<Grid item md={12}>
{profile === undefined ? (
@@ -80,11 +80,6 @@ const CreatorAnalyticsPage: React.FC<CreatorAnalyticsPageProps> = ({
queries={{ stats: ccRelatedUsers }}
params={{ stats: { params: { amount, skip: 0 } } }}
render={QR.fold(LazyFullSizeLoader, ErrorBox, ({ stats }) => {
const recommendationsAnalyzed = stats.content.reduce(
(acc, c) => acc + c.recommendedChannelCount,
0
);

return (
<Grid container spacing={2}>
<Grid item md={3} sm={6}>
@@ -100,13 +95,13 @@ const CreatorAnalyticsPage: React.FC<CreatorAnalyticsPageProps> = ({
<Grid item sm={12}>
<StatsCard
header={t('analytics:total_recommendations')}
count={recommendationsAnalyzed}
count={stats.totalRecommendations}
/>
</Grid>
<Grid item sm={12}>
<StatsCard
header={t('analytics:total_metadata')}
count={stats.totalRecommendations}
header={t('analytics:total_contributions')}
count={stats.totalContributions}
color={theme.palette.primary.main}
/>
</Grid>
2 changes: 1 addition & 1 deletion YCAI/src/i18n/en-US.ts
Original file line number Diff line number Diff line change
@@ -133,7 +133,7 @@ const resources: CustomTypeOptions['resources'] = {
recommendations_title: 'Recommendations Analyzed',
recommendations_for_other_channels: 'From other channels',
total_recommendations: 'Total recommendations',
total_metadata: 'Total metadata',
total_contributions: 'Total Contributions',
notifications_title: 'Notifications',
top_n_cc_related_to_your_channel:
'Most recommended channels on your videos:',
4 changes: 2 additions & 2 deletions YCAI/typings/react-i18next/index.d.ts
Original file line number Diff line number Diff line change
@@ -114,7 +114,7 @@ declare module 'react-i18next' {
recommendations_title: string;
recommendations_for_other_channels: string;
total_recommendations: string;
total_metadata: string;
total_contributions: string;
notifications_title: string;
top_n_cc_related_to_your_channel: string;
advertising_connected_to_your_videos_title: string;
@@ -170,7 +170,7 @@ declare module 'react-i18next' {
swagger: {
title: string;
description: string;
}
};
};
}
}
6 changes: 4 additions & 2 deletions backend/lib/automo.js
Original file line number Diff line number Diff line change
@@ -252,7 +252,7 @@ async function getMetadataFromAuthorChannelId(channelId, options) {
cappedResultsOpts
);

const totalRelatedCount = [
const totalRelatedCountFilters = [
{
$match: filter,
},
@@ -263,7 +263,7 @@ async function getMetadataFromAuthorChannelId(channelId, options) {
const [relatedTotal] = await mongo3.aggregate(
mongoc,
nconf.get('schema').metadata,
totalRelatedCount
totalRelatedCountFilters
);

const [totalRecommendedSource] = await mongo3.aggregate(
@@ -287,6 +287,7 @@ async function getMetadataFromAuthorChannelId(channelId, options) {
channelId,
authorName: null,
totalRecommendations: totalRecommendedSource?.total ?? 0,
totalContributions: relatedTotal?.total ?? 0,
score: 0,
pagination: options,
content: [],
@@ -311,6 +312,7 @@ async function getMetadataFromAuthorChannelId(channelId, options) {
channelId,
authorName,
totalRecommendations: totalRecommendedSource.total,
totalContributions: relatedTotal.total,
score,
pagination: options,
content,
1 change: 1 addition & 0 deletions packages/shared/src/models/ChannelRelated.ts
Original file line number Diff line number Diff line change
@@ -18,6 +18,7 @@ export const GetRelatedChannelsOutput = t.strict(
authorName: t.union([t.null, t.string]),
score: t.number,
totalRecommendations: t.number,
totalContributions: t.number,
pagination: t.strict({
amount: t.number,
}),