data_statistics.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. /*
  2. This file is part of Telegram Desktop,
  3. the official desktop application for the Telegram messaging service.
  4. For license and copyright information please follow this link:
  5. https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
  6. */
  7. #pragma once
  8. #include "data/data_statistics_chart.h"
  9. namespace Data {
  10. struct StatisticsMessageInteractionInfo final {
  11. MsgId messageId;
  12. StoryId storyId = StoryId(0);
  13. int viewsCount = 0;
  14. int forwardsCount = 0;
  15. int reactionsCount = 0;
  16. };
  17. struct StatisticsMessageSenderInfo final {
  18. UserId userId = UserId(0);
  19. int sentMessageCount = 0;
  20. int averageCharacterCount = 0;
  21. };
  22. struct StatisticsAdministratorActionsInfo final {
  23. UserId userId = UserId(0);
  24. int deletedMessageCount = 0;
  25. int bannedUserCount = 0;
  26. int restrictedUserCount = 0;
  27. };
  28. struct StatisticsInviterInfo final {
  29. UserId userId = UserId(0);
  30. int addedMemberCount = 0;
  31. };
  32. struct StatisticalValue final {
  33. float64 value = 0.;
  34. float64 previousValue = 0.;
  35. float64 growthRatePercentage = 0.;
  36. };
  37. struct ChannelStatistics final {
  38. [[nodiscard]] bool empty() const {
  39. return !startDate || !endDate;
  40. }
  41. [[nodiscard]] explicit operator bool() const {
  42. return !empty();
  43. }
  44. int startDate = 0;
  45. int endDate = 0;
  46. StatisticalValue memberCount;
  47. StatisticalValue meanViewCount;
  48. StatisticalValue meanShareCount;
  49. StatisticalValue meanReactionCount;
  50. StatisticalValue meanStoryViewCount;
  51. StatisticalValue meanStoryShareCount;
  52. StatisticalValue meanStoryReactionCount;
  53. float64 enabledNotificationsPercentage = 0.;
  54. StatisticalGraph memberCountGraph;
  55. StatisticalGraph joinGraph;
  56. StatisticalGraph muteGraph;
  57. StatisticalGraph viewCountByHourGraph;
  58. StatisticalGraph viewCountBySourceGraph;
  59. StatisticalGraph joinBySourceGraph;
  60. StatisticalGraph languageGraph;
  61. StatisticalGraph messageInteractionGraph;
  62. StatisticalGraph instantViewInteractionGraph;
  63. StatisticalGraph reactionsByEmotionGraph;
  64. StatisticalGraph storyInteractionsGraph;
  65. StatisticalGraph storyReactionsByEmotionGraph;
  66. std::vector<StatisticsMessageInteractionInfo> recentMessageInteractions;
  67. };
  68. struct SupergroupStatistics final {
  69. [[nodiscard]] bool empty() const {
  70. return !startDate || !endDate;
  71. }
  72. [[nodiscard]] explicit operator bool() const {
  73. return !empty();
  74. }
  75. int startDate = 0;
  76. int endDate = 0;
  77. StatisticalValue memberCount;
  78. StatisticalValue messageCount;
  79. StatisticalValue viewerCount;
  80. StatisticalValue senderCount;
  81. StatisticalGraph memberCountGraph;
  82. StatisticalGraph joinGraph;
  83. StatisticalGraph joinBySourceGraph;
  84. StatisticalGraph languageGraph;
  85. StatisticalGraph messageContentGraph;
  86. StatisticalGraph actionGraph;
  87. StatisticalGraph dayGraph;
  88. StatisticalGraph weekGraph;
  89. std::vector<StatisticsMessageSenderInfo> topSenders;
  90. std::vector<StatisticsAdministratorActionsInfo> topAdministrators;
  91. std::vector<StatisticsInviterInfo> topInviters;
  92. };
  93. struct MessageStatistics final {
  94. explicit operator bool() const {
  95. return !messageInteractionGraph.chart.empty() || views;
  96. }
  97. Data::StatisticalGraph messageInteractionGraph;
  98. Data::StatisticalGraph reactionsByEmotionGraph;
  99. int publicForwards = 0;
  100. int privateForwards = 0;
  101. int views = 0;
  102. int reactions = 0;
  103. };
  104. // At the moment, the structures are identical.
  105. using StoryStatistics = MessageStatistics;
  106. struct AnyStatistics final {
  107. Data::ChannelStatistics channel;
  108. Data::SupergroupStatistics supergroup;
  109. Data::MessageStatistics message;
  110. Data::StoryStatistics story;
  111. };
  112. struct RecentPostId final {
  113. FullMsgId messageId;
  114. FullStoryId storyId;
  115. [[nodiscard]] bool valid() const {
  116. return messageId || storyId;
  117. }
  118. explicit operator bool() const {
  119. return valid();
  120. }
  121. friend inline auto operator<=>(RecentPostId, RecentPostId) = default;
  122. friend inline bool operator==(RecentPostId, RecentPostId) = default;
  123. };
  124. struct PublicForwardsSlice final {
  125. using OffsetToken = QString;
  126. QVector<RecentPostId> list;
  127. int total = 0;
  128. bool allLoaded = false;
  129. OffsetToken token;
  130. };
  131. } // namespace Data