diff --git a/Telegram/Resources/langs/lang.strings b/Telegram/Resources/langs/lang.strings index f2c938103..f9576d19a 100644 --- a/Telegram/Resources/langs/lang.strings +++ b/Telegram/Resources/langs/lang.strings @@ -4364,6 +4364,9 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL "lng_chart_title_language" = "Languages"; "lng_chart_title_message_interaction" = "Interactions"; "lng_chart_title_instant_view_interaction" = "IV Interactions"; +"lng_chart_title_reactions_by_emotion" = "Reactions"; +"lng_chart_title_story_interactions" = "Story Interactions"; +"lng_chart_title_story_reactions_by_emotion" = "Story reactions"; "lng_chart_title_group_join" = "Group members"; "lng_chart_title_group_join_by_source" = "New members by source"; diff --git a/Telegram/SourceFiles/api/api_statistics.cpp b/Telegram/SourceFiles/api/api_statistics.cpp index 1f5c093a6..f8d21c153 100644 --- a/Telegram/SourceFiles/api/api_statistics.cpp +++ b/Telegram/SourceFiles/api/api_statistics.cpp @@ -110,6 +110,15 @@ constexpr auto kCheckRequestsTimer = 10 * crl::time(1000); .instantViewInteractionGraph = StatisticalGraphFromTL( data.viv_interactions_graph()), + .reactionsByEmotionGraph = StatisticalGraphFromTL( + data.vreactions_by_emotion_graph()), + + .storyInteractionsGraph = StatisticalGraphFromTL( + data.vstory_interactions_graph()), + + .storyReactionsByEmotionGraph = StatisticalGraphFromTL( + data.vstory_reactions_by_emotion_graph()), + .recentMessageInteractions = std::move(recentMessages), }; } @@ -438,12 +447,14 @@ void MessageStatistics::request(Fn done) { } const auto requestFirstPublicForwards = [=]( const Data::StatisticalGraph &messageGraph, + const Data::StatisticalGraph &reactionsGraph, const Data::StatisticsMessageInteractionInfo &info) { _publicForwards.request({}, [=](Data::PublicForwardsSlice slice) { const auto total = slice.total; _firstSlice = std::move(slice); done({ .messageInteractionGraph = messageGraph, + .reactionsByEmotionGraph = reactionsGraph, .publicForwards = total, .privateForwards = info.forwardsCount - total, .views = info.viewsCount, @@ -452,7 +463,8 @@ void MessageStatistics::request(Fn done) { }; const auto requestPrivateForwards = [=]( - const Data::StatisticalGraph &messageGraph) { + const Data::StatisticalGraph &messageGraph, + const Data::StatisticalGraph &reactionsGraph) { api().request(MTPchannels_GetMessages( channel()->inputChannel, MTP_vector( @@ -488,9 +500,12 @@ void MessageStatistics::request(Fn done) { return Data::StatisticsMessageInteractionInfo(); }); - requestFirstPublicForwards(messageGraph, std::move(info)); + requestFirstPublicForwards( + messageGraph, + reactionsGraph, + std::move(info)); }).fail([=](const MTP::Error &error) { - requestFirstPublicForwards(messageGraph, {}); + requestFirstPublicForwards(messageGraph, reactionsGraph, {}); }).send(); }; @@ -499,10 +514,12 @@ void MessageStatistics::request(Fn done) { channel()->inputChannel, MTP_int(_fullId.msg.bare) )).done([=](const MTPstats_MessageStats &result) { + const auto &data = result.data(); requestPrivateForwards( - StatisticalGraphFromTL(result.data().vviews_graph())); + StatisticalGraphFromTL(data.vviews_graph()), + StatisticalGraphFromTL(data.vreactions_by_emotion_graph())); }).fail([=](const MTP::Error &error) { - requestPrivateForwards({}); + requestPrivateForwards({}, {}); }).send(); } diff --git a/Telegram/SourceFiles/data/data_statistics.h b/Telegram/SourceFiles/data/data_statistics.h index ce59e4d58..46f0009ee 100644 --- a/Telegram/SourceFiles/data/data_statistics.h +++ b/Telegram/SourceFiles/data/data_statistics.h @@ -67,6 +67,9 @@ struct ChannelStatistics final { StatisticalGraph languageGraph; StatisticalGraph messageInteractionGraph; StatisticalGraph instantViewInteractionGraph; + StatisticalGraph reactionsByEmotionGraph; + StatisticalGraph storyInteractionsGraph; + StatisticalGraph storyReactionsByEmotionGraph; std::vector recentMessageInteractions; @@ -108,6 +111,7 @@ struct MessageStatistics final { return !messageInteractionGraph.chart.empty() || views; } Data::StatisticalGraph messageInteractionGraph; + Data::StatisticalGraph reactionsByEmotionGraph; int publicForwards = 0; int privateForwards = 0; int views = 0; diff --git a/Telegram/SourceFiles/info/statistics/info_statistics_inner_widget.cpp b/Telegram/SourceFiles/info/statistics/info_statistics_inner_widget.cpp index bbd05b98f..c62ef93f6 100644 --- a/Telegram/SourceFiles/info/statistics/info_statistics_inner_widget.cpp +++ b/Telegram/SourceFiles/info/statistics/info_statistics_inner_widget.cpp @@ -206,6 +206,18 @@ void FillStatistic( stats.channel.instantViewInteractionGraph, tr::lng_chart_title_instant_view_interaction(), Type::DoubleLinear); + addChart( + stats.channel.reactionsByEmotionGraph, + tr::lng_chart_title_reactions_by_emotion(), + Type::Bar); + addChart( + stats.channel.storyInteractionsGraph, + tr::lng_chart_title_story_interactions(), + Type::DoubleLinear); + addChart( + stats.channel.storyReactionsByEmotionGraph, + tr::lng_chart_title_story_reactions_by_emotion(), + Type::Bar); } else if (stats.supergroup) { addChart( stats.supergroup.memberCountGraph, @@ -244,6 +256,10 @@ void FillStatistic( stats.message.messageInteractionGraph, tr::lng_chart_title_message_interaction(), Type::DoubleLinear); + addChart( + stats.message.reactionsByEmotionGraph, + tr::lng_chart_title_reactions_by_emotion(), + Type::Bar); } }