mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Added deserialization from JSON to statistics data to API.
This commit is contained in:
parent
c0219cb95d
commit
029e0c9488
1 changed files with 43 additions and 0 deletions
|
@ -11,10 +11,25 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "data/data_channel.h"
|
#include "data/data_channel.h"
|
||||||
#include "data/data_peer.h"
|
#include "data/data_peer.h"
|
||||||
#include "main/main_session.h"
|
#include "main/main_session.h"
|
||||||
|
#include "statistics/statistics_data_deserialize.h"
|
||||||
|
|
||||||
namespace Api {
|
namespace Api {
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
|
[[nodiscard]] Data::StatisticalGraph StatisticalGraphFromTL(
|
||||||
|
const MTPStatsGraph &tl) {
|
||||||
|
return tl.match([&](const MTPDstatsGraph &d) {
|
||||||
|
using namespace Statistic;
|
||||||
|
return Data::StatisticalGraph{
|
||||||
|
StatisticalChartFromJSON(qs(d.vjson().data().vdata()).toUtf8()),
|
||||||
|
};
|
||||||
|
}, [&](const MTPDstatsGraphAsync &data) {
|
||||||
|
return Data::StatisticalGraph{ Data::StatisticalChart() };
|
||||||
|
}, [&](const MTPDstatsGraphError &data) {
|
||||||
|
return Data::StatisticalGraph{ Data::StatisticalChart() };
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
[[nodiscard]] Data::StatisticalValue StatisticalValueFromTL(
|
[[nodiscard]] Data::StatisticalValue StatisticalValueFromTL(
|
||||||
const MTPStatsAbsValueAndPrev &tl) {
|
const MTPStatsAbsValueAndPrev &tl) {
|
||||||
const auto current = tl.data().vcurrent().v;
|
const auto current = tl.data().vcurrent().v;
|
||||||
|
@ -47,6 +62,7 @@ namespace {
|
||||||
.forwardsCount = tl.data().vforwards().v,
|
.forwardsCount = tl.data().vforwards().v,
|
||||||
};
|
};
|
||||||
}) | ranges::to_vector;
|
}) | ranges::to_vector;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
.startDate = data.vperiod().data().vmin_date().v,
|
.startDate = data.vperiod().data().vmin_date().v,
|
||||||
.endDate = data.vperiod().data().vmax_date().v,
|
.endDate = data.vperiod().data().vmax_date().v,
|
||||||
|
@ -57,6 +73,33 @@ namespace {
|
||||||
|
|
||||||
.enabledNotificationsPercentage = unmuted,
|
.enabledNotificationsPercentage = unmuted,
|
||||||
|
|
||||||
|
.memberCountGraph = StatisticalGraphFromTL(
|
||||||
|
data.vgrowth_graph()),
|
||||||
|
|
||||||
|
.joinGraph = StatisticalGraphFromTL(
|
||||||
|
data.vfollowers_graph()),
|
||||||
|
|
||||||
|
.muteGraph = StatisticalGraphFromTL(
|
||||||
|
data.vmute_graph()),
|
||||||
|
|
||||||
|
.viewCountByHourGraph = StatisticalGraphFromTL(
|
||||||
|
data.vtop_hours_graph()),
|
||||||
|
|
||||||
|
.viewCountBySourceGraph = StatisticalGraphFromTL(
|
||||||
|
data.vviews_by_source_graph()),
|
||||||
|
|
||||||
|
.joinBySourceGraph = StatisticalGraphFromTL(
|
||||||
|
data.vnew_followers_by_source_graph()),
|
||||||
|
|
||||||
|
.languageGraph = StatisticalGraphFromTL(
|
||||||
|
data.vlanguages_graph()),
|
||||||
|
|
||||||
|
.messageInteractionGraph = StatisticalGraphFromTL(
|
||||||
|
data.vinteractions_graph()),
|
||||||
|
|
||||||
|
.instantViewInteractionGraph = StatisticalGraphFromTL(
|
||||||
|
data.viv_interactions_graph()),
|
||||||
|
|
||||||
.recentMessageInteractions = std::move(recentMessages),
|
.recentMessageInteractions = std::move(recentMessages),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue