mirror of
https://github.com/telegramdesktop/tdesktop
synced 2025-02-25 10:01:00 +00:00
Added charts of story statistics to statistics info.
This commit is contained in:
parent
1056a5cc8e
commit
2bb8850e69
@ -4314,6 +4314,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||||||
|
|
||||||
"lng_stats_title" = "Statistics";
|
"lng_stats_title" = "Statistics";
|
||||||
"lng_stats_message_title" = "Message Statistic";
|
"lng_stats_message_title" = "Message Statistic";
|
||||||
|
"lng_stats_story_title" = "Story Statistic";
|
||||||
"lng_stats_zoom_out" = "Zoom Out";
|
"lng_stats_zoom_out" = "Zoom Out";
|
||||||
|
|
||||||
"lng_stats_overview_title" = "Overview";
|
"lng_stats_overview_title" = "Overview";
|
||||||
|
@ -251,15 +251,20 @@ void FillStatistic(
|
|||||||
stats.supergroup.weekGraph,
|
stats.supergroup.weekGraph,
|
||||||
tr::lng_chart_title_group_week(),
|
tr::lng_chart_title_group_week(),
|
||||||
Type::StackLinear);
|
Type::StackLinear);
|
||||||
} else if (stats.message) {
|
} else {
|
||||||
addChart(
|
auto &messageOrStory = stats.message
|
||||||
stats.message.messageInteractionGraph,
|
? stats.message
|
||||||
tr::lng_chart_title_message_interaction(),
|
: stats.story;
|
||||||
Type::DoubleLinear);
|
if (messageOrStory) {
|
||||||
addChart(
|
addChart(
|
||||||
stats.message.reactionsByEmotionGraph,
|
messageOrStory.messageInteractionGraph,
|
||||||
tr::lng_chart_title_reactions_by_emotion(),
|
tr::lng_chart_title_message_interaction(),
|
||||||
Type::Bar);
|
Type::DoubleLinear);
|
||||||
|
addChart(
|
||||||
|
messageOrStory.reactionsByEmotionGraph,
|
||||||
|
tr::lng_chart_title_reactions_by_emotion(),
|
||||||
|
Type::Bar);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -376,11 +381,12 @@ void FillOverview(
|
|||||||
};
|
};
|
||||||
|
|
||||||
const auto isChannel = (!!channel);
|
const auto isChannel = (!!channel);
|
||||||
const auto isMessage = (!!stats.message);
|
const auto &messageOrStory = stats.message ? stats.message : stats.story;
|
||||||
|
const auto isMessage = (!!messageOrStory);
|
||||||
const auto topLeftLabel = isChannel
|
const auto topLeftLabel = isChannel
|
||||||
? addPrimary(channel.memberCount)
|
? addPrimary(channel.memberCount)
|
||||||
: isMessage
|
: isMessage
|
||||||
? addPrimary({ .value = float64(stats.message.views) })
|
? addPrimary({ .value = float64(messageOrStory.views) })
|
||||||
: addPrimary(supergroup.memberCount);
|
: addPrimary(supergroup.memberCount);
|
||||||
const auto topRightLabel = isChannel
|
const auto topRightLabel = isChannel
|
||||||
? Ui::CreateChild<Ui::FlatLabel>(
|
? Ui::CreateChild<Ui::FlatLabel>(
|
||||||
@ -389,17 +395,17 @@ void FillOverview(
|
|||||||
* std::round(channel.enabledNotificationsPercentage * 100.)),
|
* std::round(channel.enabledNotificationsPercentage * 100.)),
|
||||||
st::statisticsOverviewValue)
|
st::statisticsOverviewValue)
|
||||||
: isMessage
|
: isMessage
|
||||||
? addPrimary({ .value = float64(stats.message.publicForwards) })
|
? addPrimary({ .value = float64(messageOrStory.publicForwards) })
|
||||||
: addPrimary(supergroup.messageCount);
|
: addPrimary(supergroup.messageCount);
|
||||||
const auto bottomLeftLabel = isChannel
|
const auto bottomLeftLabel = isChannel
|
||||||
? addPrimary(channel.meanViewCount)
|
? addPrimary(channel.meanViewCount)
|
||||||
: isMessage
|
: isMessage
|
||||||
? addPrimary({ .value = float64(stats.message.reactions) })
|
? addPrimary({ .value = float64(messageOrStory.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 = float64(stats.message.privateForwards) })
|
? addPrimary({ .value = float64(messageOrStory.privateForwards) })
|
||||||
: addPrimary(supergroup.senderCount);
|
: addPrimary(supergroup.senderCount);
|
||||||
if (const auto &s = channel) {
|
if (const auto &s = channel) {
|
||||||
addSub(
|
addSub(
|
||||||
@ -435,7 +441,7 @@ void FillOverview(
|
|||||||
bottomRightLabel,
|
bottomRightLabel,
|
||||||
s.senderCount,
|
s.senderCount,
|
||||||
tr::lng_stats_overview_group_mean_post_count);
|
tr::lng_stats_overview_group_mean_post_count);
|
||||||
} else if (const auto &s = stats.message) {
|
} else if (const auto &s = messageOrStory) {
|
||||||
if (s.views >= 0) {
|
if (s.views >= 0) {
|
||||||
addSub(
|
addSub(
|
||||||
topLeftLabel,
|
topLeftLabel,
|
||||||
@ -564,7 +570,7 @@ void InnerWidget::load() {
|
|||||||
|
|
||||||
_showFinished.events(
|
_showFinished.events(
|
||||||
) | rpl::take(1) | rpl::start_with_next([=] {
|
) | rpl::take(1) | rpl::start_with_next([=] {
|
||||||
if (!_contextId) {
|
if (!_contextId && !_storyId) {
|
||||||
descriptor.api->request(
|
descriptor.api->request(
|
||||||
) | rpl::start_with_done([=] {
|
) | rpl::start_with_done([=] {
|
||||||
_state.stats = Data::AnyStatistics{
|
_state.stats = Data::AnyStatistics{
|
||||||
@ -577,13 +583,22 @@ void InnerWidget::load() {
|
|||||||
}, lifetime());
|
}, lifetime());
|
||||||
} else {
|
} else {
|
||||||
const auto lifetimeApi = lifetime().make_state<rpl::lifetime>();
|
const auto lifetimeApi = lifetime().make_state<rpl::lifetime>();
|
||||||
const auto api = lifetimeApi->make_state<Api::MessageStatistics>(
|
const auto api = _storyId
|
||||||
descriptor.peer->asChannel(),
|
? lifetimeApi->make_state<Api::MessageStatistics>(
|
||||||
_contextId);
|
descriptor.peer->asChannel(),
|
||||||
|
_storyId)
|
||||||
|
: lifetimeApi->make_state<Api::MessageStatistics>(
|
||||||
|
descriptor.peer->asChannel(),
|
||||||
|
_contextId);
|
||||||
|
|
||||||
api->request([=](const Data::MessageStatistics &data) {
|
api->request([=](const Data::StoryStatistics &data) {
|
||||||
_state.stats = Data::AnyStatistics{ .message = data };
|
_state.stats = Data::AnyStatistics{
|
||||||
_state.publicForwardsFirstSlice = api->firstSlice();
|
.message = _contextId ? data : Data::StoryStatistics(),
|
||||||
|
.story = _storyId ? data : Data::StoryStatistics(),
|
||||||
|
};
|
||||||
|
if (_contextId) {
|
||||||
|
_state.publicForwardsFirstSlice = api->firstSlice();
|
||||||
|
}
|
||||||
fill();
|
fill();
|
||||||
|
|
||||||
finishLoading();
|
finishLoading();
|
||||||
|
@ -93,6 +93,8 @@ bool Widget::showInternal(not_null<ContentMemento*> memento) {
|
|||||||
rpl::producer<QString> Widget::title() {
|
rpl::producer<QString> Widget::title() {
|
||||||
return controller()->statisticsContextId()
|
return controller()->statisticsContextId()
|
||||||
? tr::lng_stats_message_title()
|
? tr::lng_stats_message_title()
|
||||||
|
: controller()->statisticsStoryId()
|
||||||
|
? tr::lng_stats_story_title()
|
||||||
: tr::lng_stats_title();
|
: tr::lng_stats_title();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user