mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Added statistical values for stories to overview in statistics info.
This commit is contained in:
parent
6de95fc4ed
commit
dfe55b26a2
4 changed files with 74 additions and 14 deletions
|
@ -4330,6 +4330,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
"lng_stats_overview_member_count" = "Followers";
|
"lng_stats_overview_member_count" = "Followers";
|
||||||
"lng_stats_overview_mean_view_count" = "Views Per Post";
|
"lng_stats_overview_mean_view_count" = "Views Per Post";
|
||||||
"lng_stats_overview_mean_share_count" = "Shared Per Post";
|
"lng_stats_overview_mean_share_count" = "Shared Per Post";
|
||||||
|
"lng_stats_overview_mean_reactions_count" = "Reactions Per Post";
|
||||||
|
"lng_stats_overview_mean_story_view_count" = "Views Per Story";
|
||||||
|
"lng_stats_overview_mean_story_share_count" = "Shared Per Story";
|
||||||
|
"lng_stats_overview_mean_story_reactions_count" = "Reactions Per Story";
|
||||||
"lng_stats_overview_enabled_notifications" = "Enabled Notifications";
|
"lng_stats_overview_enabled_notifications" = "Enabled Notifications";
|
||||||
"lng_stats_overview_messages" = "Messages";
|
"lng_stats_overview_messages" = "Messages";
|
||||||
"lng_stats_overview_group_mean_view_count" = "Viewing Members";
|
"lng_stats_overview_group_mean_view_count" = "Viewing Members";
|
||||||
|
|
|
@ -93,6 +93,13 @@ constexpr auto kCheckRequestsTimer = 10 * crl::time(1000);
|
||||||
.meanReactionCount = StatisticalValueFromTL(
|
.meanReactionCount = StatisticalValueFromTL(
|
||||||
data.vreactions_per_post()),
|
data.vreactions_per_post()),
|
||||||
|
|
||||||
|
.meanStoryViewCount = StatisticalValueFromTL(
|
||||||
|
data.vviews_per_story()),
|
||||||
|
.meanStoryShareCount = StatisticalValueFromTL(
|
||||||
|
data.vshares_per_story()),
|
||||||
|
.meanStoryReactionCount = StatisticalValueFromTL(
|
||||||
|
data.vreactions_per_story()),
|
||||||
|
|
||||||
.enabledNotificationsPercentage = unmuted,
|
.enabledNotificationsPercentage = unmuted,
|
||||||
|
|
||||||
.memberCountGraph = StatisticalGraphFromTL(
|
.memberCountGraph = StatisticalGraphFromTL(
|
||||||
|
|
|
@ -58,6 +58,9 @@ struct ChannelStatistics final {
|
||||||
StatisticalValue meanViewCount;
|
StatisticalValue meanViewCount;
|
||||||
StatisticalValue meanShareCount;
|
StatisticalValue meanShareCount;
|
||||||
StatisticalValue meanReactionCount;
|
StatisticalValue meanReactionCount;
|
||||||
|
StatisticalValue meanStoryViewCount;
|
||||||
|
StatisticalValue meanStoryShareCount;
|
||||||
|
StatisticalValue meanStoryReactionCount;
|
||||||
|
|
||||||
float64 enabledNotificationsPercentage = 0.;
|
float64 enabledNotificationsPercentage = 0.;
|
||||||
|
|
||||||
|
|
|
@ -301,15 +301,18 @@ void AddHeader(
|
||||||
|
|
||||||
void FillOverview(
|
void FillOverview(
|
||||||
not_null<Ui::VerticalLayout*> content,
|
not_null<Ui::VerticalLayout*> content,
|
||||||
const Data::AnyStatistics &stats) {
|
const Data::AnyStatistics &stats,
|
||||||
|
bool isChannelStoryStats) {
|
||||||
using Value = Data::StatisticalValue;
|
using Value = Data::StatisticalValue;
|
||||||
|
|
||||||
const auto &channel = stats.channel;
|
const auto &channel = stats.channel;
|
||||||
const auto &supergroup = stats.supergroup;
|
const auto &supergroup = stats.supergroup;
|
||||||
|
|
||||||
Ui::AddSkip(content, st::statisticsLayerOverviewMargins.top());
|
if (!isChannelStoryStats) {
|
||||||
AddHeader(content, tr::lng_stats_overview_title, stats);
|
Ui::AddSkip(content, st::statisticsLayerOverviewMargins.top());
|
||||||
Ui::AddSkip(content);
|
AddHeader(content, tr::lng_stats_overview_title, stats);
|
||||||
|
Ui::AddSkip(content);
|
||||||
|
}
|
||||||
|
|
||||||
struct Second final {
|
struct Second final {
|
||||||
QColor color;
|
QColor color;
|
||||||
|
@ -318,7 +321,7 @@ void FillOverview(
|
||||||
|
|
||||||
const auto parseSecond = [&](const Value &v) -> Second {
|
const auto parseSecond = [&](const Value &v) -> Second {
|
||||||
const auto diff = v.value - v.previousValue;
|
const auto diff = v.value - v.previousValue;
|
||||||
if (!diff) {
|
if (!diff || !v.previousValue) {
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
constexpr auto kTooMuchDiff = int(1'000'000);
|
constexpr auto kTooMuchDiff = int(1'000'000);
|
||||||
|
@ -385,12 +388,21 @@ void FillOverview(
|
||||||
const auto isChannel = (!!channel);
|
const auto isChannel = (!!channel);
|
||||||
const auto &messageOrStory = stats.message ? stats.message : stats.story;
|
const auto &messageOrStory = stats.message ? stats.message : stats.story;
|
||||||
const auto isMessage = (!!messageOrStory);
|
const auto isMessage = (!!messageOrStory);
|
||||||
const auto topLeftLabel = isChannel
|
|
||||||
|
const auto hasPostReactions = isChannel
|
||||||
|
&& (channel.meanReactionCount.value
|
||||||
|
|| channel.meanReactionCount.previousValue);
|
||||||
|
|
||||||
|
const auto topLeftLabel = (isChannelStoryStats && isChannel)
|
||||||
|
? addPrimary(channel.meanShareCount)
|
||||||
|
: isChannel
|
||||||
? addPrimary(channel.memberCount)
|
? addPrimary(channel.memberCount)
|
||||||
: isMessage
|
: isMessage
|
||||||
? addPrimary({ .value = float64(messageOrStory.views) })
|
? addPrimary({ .value = float64(messageOrStory.views) })
|
||||||
: addPrimary(supergroup.memberCount);
|
: addPrimary(supergroup.memberCount);
|
||||||
const auto topRightLabel = isChannel
|
const auto topRightLabel = (isChannelStoryStats && isChannel)
|
||||||
|
? addPrimary(channel.meanStoryShareCount)
|
||||||
|
: isChannel
|
||||||
? Ui::CreateChild<Ui::FlatLabel>(
|
? Ui::CreateChild<Ui::FlatLabel>(
|
||||||
container,
|
container,
|
||||||
QString("%1%").arg(0.01
|
QString("%1%").arg(0.01
|
||||||
|
@ -399,17 +411,48 @@ void FillOverview(
|
||||||
: isMessage
|
: isMessage
|
||||||
? addPrimary({ .value = float64(messageOrStory.publicForwards) })
|
? addPrimary({ .value = float64(messageOrStory.publicForwards) })
|
||||||
: addPrimary(supergroup.messageCount);
|
: addPrimary(supergroup.messageCount);
|
||||||
const auto bottomLeftLabel = isChannel
|
const auto bottomLeftLabel = (isChannelStoryStats && isChannel)
|
||||||
|
? addPrimary(hasPostReactions
|
||||||
|
? channel.meanReactionCount
|
||||||
|
: channel.meanStoryReactionCount)
|
||||||
|
: isChannel
|
||||||
? addPrimary(channel.meanViewCount)
|
? addPrimary(channel.meanViewCount)
|
||||||
: isMessage
|
: isMessage
|
||||||
? addPrimary({ .value = float64(messageOrStory.reactions) })
|
? addPrimary({ .value = float64(messageOrStory.reactions) })
|
||||||
: addPrimary(supergroup.viewerCount);
|
: addPrimary(supergroup.viewerCount);
|
||||||
const auto bottomRightLabel = isChannel
|
const auto bottomRightLabel = (isChannelStoryStats && isChannel)
|
||||||
? addPrimary(channel.meanShareCount)
|
? addPrimary(!hasPostReactions
|
||||||
|
? Value{ .value = -1 }
|
||||||
|
: channel.meanStoryReactionCount)
|
||||||
|
: isChannel
|
||||||
|
? addPrimary(channel.meanStoryViewCount)
|
||||||
: isMessage
|
: isMessage
|
||||||
? addPrimary({ .value = float64(messageOrStory.privateForwards) })
|
? addPrimary({ .value = float64(messageOrStory.privateForwards) })
|
||||||
: addPrimary(supergroup.senderCount);
|
: addPrimary(supergroup.senderCount);
|
||||||
if (const auto &s = channel) {
|
if (isChannelStoryStats && isChannel) {
|
||||||
|
addSub(
|
||||||
|
topLeftLabel,
|
||||||
|
channel.meanShareCount,
|
||||||
|
tr::lng_stats_overview_mean_share_count);
|
||||||
|
addSub(
|
||||||
|
topRightLabel,
|
||||||
|
channel.meanStoryShareCount,
|
||||||
|
tr::lng_stats_overview_mean_story_share_count);
|
||||||
|
addSub(
|
||||||
|
bottomLeftLabel,
|
||||||
|
hasPostReactions
|
||||||
|
? channel.meanReactionCount
|
||||||
|
: channel.meanStoryReactionCount,
|
||||||
|
hasPostReactions
|
||||||
|
? tr::lng_stats_overview_mean_reactions_count
|
||||||
|
: tr::lng_stats_overview_mean_story_reactions_count);
|
||||||
|
if (hasPostReactions) {
|
||||||
|
addSub(
|
||||||
|
bottomRightLabel,
|
||||||
|
channel.meanStoryReactionCount,
|
||||||
|
tr::lng_stats_overview_mean_story_reactions_count);
|
||||||
|
}
|
||||||
|
} else if (const auto &s = channel) {
|
||||||
addSub(
|
addSub(
|
||||||
topLeftLabel,
|
topLeftLabel,
|
||||||
s.memberCount,
|
s.memberCount,
|
||||||
|
@ -424,8 +467,8 @@ void FillOverview(
|
||||||
tr::lng_stats_overview_mean_view_count);
|
tr::lng_stats_overview_mean_view_count);
|
||||||
addSub(
|
addSub(
|
||||||
bottomRightLabel,
|
bottomRightLabel,
|
||||||
s.meanShareCount,
|
s.meanStoryViewCount,
|
||||||
tr::lng_stats_overview_mean_share_count);
|
tr::lng_stats_overview_mean_story_view_count);
|
||||||
} else if (const auto &s = supergroup) {
|
} else if (const auto &s = supergroup) {
|
||||||
addSub(
|
addSub(
|
||||||
topLeftLabel,
|
topLeftLabel,
|
||||||
|
@ -636,7 +679,10 @@ void InnerWidget::fill() {
|
||||||
Ui::AddDivider(inner);
|
Ui::AddDivider(inner);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
FillOverview(inner, _state.stats);
|
FillOverview(inner, _state.stats, false);
|
||||||
|
if (_state.stats.channel) {
|
||||||
|
FillOverview(inner, _state.stats, true);
|
||||||
|
}
|
||||||
FillStatistic(inner, descriptor, _state.stats);
|
FillStatistic(inner, descriptor, _state.stats);
|
||||||
const auto &channel = _state.stats.channel;
|
const auto &channel = _state.stats.channel;
|
||||||
const auto &supergroup = _state.stats.supergroup;
|
const auto &supergroup = _state.stats.supergroup;
|
||||||
|
|
Loading…
Add table
Reference in a new issue