Added reactions count to overview in statistics info.
This commit is contained in:
		
							parent
							
								
									173a5046e8
								
							
						
					
					
						commit
						f88eee8047
					
				
					 3 changed files with 20 additions and 3 deletions
				
			
		| 
						 | 
					@ -458,6 +458,7 @@ void MessageStatistics::request(Fn<void(Data::MessageStatistics)> done) {
 | 
				
			||||||
				.publicForwards = total,
 | 
									.publicForwards = total,
 | 
				
			||||||
				.privateForwards = info.forwardsCount - total,
 | 
									.privateForwards = info.forwardsCount - total,
 | 
				
			||||||
				.views = info.viewsCount,
 | 
									.views = info.viewsCount,
 | 
				
			||||||
 | 
									.reactions = info.reactionsCount,
 | 
				
			||||||
			});
 | 
								});
 | 
				
			||||||
		});
 | 
							});
 | 
				
			||||||
	};
 | 
						};
 | 
				
			||||||
| 
						 | 
					@ -474,6 +475,13 @@ void MessageStatistics::request(Fn<void(Data::MessageStatistics)> done) {
 | 
				
			||||||
			const auto process = [&](const MTPVector<MTPMessage> &messages) {
 | 
								const auto process = [&](const MTPVector<MTPMessage> &messages) {
 | 
				
			||||||
				const auto &message = messages.v.front();
 | 
									const auto &message = messages.v.front();
 | 
				
			||||||
				return message.match([&](const MTPDmessage &data) {
 | 
									return message.match([&](const MTPDmessage &data) {
 | 
				
			||||||
 | 
										auto reactionsCount = 0;
 | 
				
			||||||
 | 
										if (const auto tlReactions = data.vreactions()) {
 | 
				
			||||||
 | 
											const auto &tlCounts = tlReactions->data().vresults();
 | 
				
			||||||
 | 
											for (const auto &tlCount : tlCounts.v) {
 | 
				
			||||||
 | 
												reactionsCount += tlCount.data().vcount().v;
 | 
				
			||||||
 | 
											}
 | 
				
			||||||
 | 
										}
 | 
				
			||||||
					return Data::StatisticsMessageInteractionInfo{
 | 
										return Data::StatisticsMessageInteractionInfo{
 | 
				
			||||||
						.messageId = IdFromMessage(message),
 | 
											.messageId = IdFromMessage(message),
 | 
				
			||||||
						.viewsCount = data.vviews()
 | 
											.viewsCount = data.vviews()
 | 
				
			||||||
| 
						 | 
					@ -482,6 +490,7 @@ void MessageStatistics::request(Fn<void(Data::MessageStatistics)> done) {
 | 
				
			||||||
						.forwardsCount = data.vforwards()
 | 
											.forwardsCount = data.vforwards()
 | 
				
			||||||
							? data.vforwards()->v
 | 
												? data.vforwards()->v
 | 
				
			||||||
							: 0,
 | 
												: 0,
 | 
				
			||||||
 | 
											.reactionsCount = reactionsCount,
 | 
				
			||||||
					};
 | 
										};
 | 
				
			||||||
				}, [](const MTPDmessageEmpty &) {
 | 
									}, [](const MTPDmessageEmpty &) {
 | 
				
			||||||
					return Data::StatisticsMessageInteractionInfo();
 | 
										return Data::StatisticsMessageInteractionInfo();
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -15,6 +15,7 @@ struct StatisticsMessageInteractionInfo final {
 | 
				
			||||||
	MsgId messageId;
 | 
						MsgId messageId;
 | 
				
			||||||
	int viewsCount = 0;
 | 
						int viewsCount = 0;
 | 
				
			||||||
	int forwardsCount = 0;
 | 
						int forwardsCount = 0;
 | 
				
			||||||
 | 
						int reactionsCount = 0;
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
struct StatisticsMessageSenderInfo final {
 | 
					struct StatisticsMessageSenderInfo final {
 | 
				
			||||||
| 
						 | 
					@ -115,6 +116,7 @@ struct MessageStatistics final {
 | 
				
			||||||
	int publicForwards = 0;
 | 
						int publicForwards = 0;
 | 
				
			||||||
	int privateForwards = 0;
 | 
						int privateForwards = 0;
 | 
				
			||||||
	int views = 0;
 | 
						int views = 0;
 | 
				
			||||||
 | 
						int reactions = 0;
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
struct AnyStatistics final {
 | 
					struct AnyStatistics final {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -394,12 +394,12 @@ void FillOverview(
 | 
				
			||||||
	const auto bottomLeftLabel = isChannel
 | 
						const auto bottomLeftLabel = isChannel
 | 
				
			||||||
		? addPrimary(channel.meanViewCount)
 | 
							? addPrimary(channel.meanViewCount)
 | 
				
			||||||
		: isMessage
 | 
							: isMessage
 | 
				
			||||||
		? addPrimary({ .value = float64(stats.message.privateForwards) })
 | 
							? addPrimary({ .value = float64(stats.message.reactions) })
 | 
				
			||||||
		: addPrimary(supergroup.viewerCount);
 | 
							: addPrimary(supergroup.viewerCount);
 | 
				
			||||||
	const auto bottomRightLabel = isChannel
 | 
						const auto bottomRightLabel = isChannel
 | 
				
			||||||
		? addPrimary(channel.meanShareCount)
 | 
							? addPrimary(channel.meanShareCount)
 | 
				
			||||||
		: isMessage
 | 
							: isMessage
 | 
				
			||||||
		? addPrimary({ .value = -1. })
 | 
							? addPrimary({ .value = float64(stats.message.privateForwards) })
 | 
				
			||||||
		: addPrimary(supergroup.senderCount);
 | 
							: addPrimary(supergroup.senderCount);
 | 
				
			||||||
	if (const auto &s = channel) {
 | 
						if (const auto &s = channel) {
 | 
				
			||||||
		addSub(
 | 
							addSub(
 | 
				
			||||||
| 
						 | 
					@ -448,10 +448,16 @@ void FillOverview(
 | 
				
			||||||
				{},
 | 
									{},
 | 
				
			||||||
				tr::lng_stats_overview_message_public_shares);
 | 
									tr::lng_stats_overview_message_public_shares);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		if (s.privateForwards >= 0) {
 | 
							if (s.reactions >= 0) {
 | 
				
			||||||
			addSub(
 | 
								addSub(
 | 
				
			||||||
				bottomLeftLabel,
 | 
									bottomLeftLabel,
 | 
				
			||||||
				{},
 | 
									{},
 | 
				
			||||||
 | 
									tr::lng_manage_peer_reactions);
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							if (s.privateForwards >= 0) {
 | 
				
			||||||
 | 
								addSub(
 | 
				
			||||||
 | 
									bottomRightLabel,
 | 
				
			||||||
 | 
									{},
 | 
				
			||||||
				tr::lng_stats_overview_message_private_shares);
 | 
									tr::lng_stats_overview_message_private_shares);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		
		Reference in a new issue