FIX: removes uncessary reports loading (#6119)
This commit is contained in:
@@ -4,6 +4,28 @@ import AdminDashboardNext from "admin/models/admin-dashboard-next";
|
||||
import Report from "admin/models/report";
|
||||
import PeriodComputationMixin from "admin/mixins/period-computation";
|
||||
|
||||
const ACTIVITY_METRICS_REPORTS = [
|
||||
"page_view_total_reqs",
|
||||
"visits",
|
||||
"time_to_first_response",
|
||||
"likes",
|
||||
"flags",
|
||||
"user_to_user_private_messages_with_replies"
|
||||
];
|
||||
|
||||
function dynamicReport(reportType) {
|
||||
return function() {
|
||||
if (this.get("period") !== "monthly") return null;
|
||||
return this.get("reports").find(x => x.type === reportType);
|
||||
}.property("reports.[]", "period");
|
||||
}
|
||||
|
||||
function staticReport(reportType) {
|
||||
return function() {
|
||||
return this.get("reports").find(x => x.type === reportType);
|
||||
}.property("reports.[]");
|
||||
}
|
||||
|
||||
export default Ember.Controller.extend(PeriodComputationMixin, {
|
||||
isLoading: false,
|
||||
dashboardFetchedAt: null,
|
||||
@@ -25,38 +47,23 @@ export default Ember.Controller.extend(PeriodComputationMixin, {
|
||||
return { table: { total: false, limit: 8 } };
|
||||
},
|
||||
|
||||
@computed("reports.[]")
|
||||
topReferredTopicsReport(reports) {
|
||||
return reports.find(x => x.type === "top_referred_topics");
|
||||
},
|
||||
signupsReport: dynamicReport("signups"),
|
||||
topicsReport: dynamicReport("topics"),
|
||||
postsReport: dynamicReport("posts"),
|
||||
dauByMauReport: dynamicReport("dau_by_mau"),
|
||||
dailyEngagedUsersReport: dynamicReport("daily_engaged_users"),
|
||||
newContributorsReport: dynamicReport("new_contributors"),
|
||||
|
||||
@computed("reports.[]")
|
||||
trendingSearchReport(reports) {
|
||||
return reports.find(x => x.type === "trending_search");
|
||||
},
|
||||
|
||||
@computed("reports.[]")
|
||||
usersByTypeReport(reports) {
|
||||
return reports.find(x => x.type === "users_by_type");
|
||||
},
|
||||
|
||||
@computed("reports.[]")
|
||||
usersByTrustLevelReport(reports) {
|
||||
return reports.find(x => x.type === "users_by_trust_level");
|
||||
},
|
||||
topReferredTopicsReport: staticReport("top_referred_topics"),
|
||||
trendingSearchReport: staticReport("trending_search"),
|
||||
usersByTypeReport: staticReport("users_by_type"),
|
||||
usersByTrustLevelReport: staticReport("users_by_trust_level"),
|
||||
|
||||
@computed("reports.[]")
|
||||
activityMetricsReports(reports) {
|
||||
return reports.filter(report => {
|
||||
return [
|
||||
"page_view_total_reqs",
|
||||
"visits",
|
||||
"time_to_first_response",
|
||||
"likes",
|
||||
"flags",
|
||||
"user_to_user_private_messages_with_replies"
|
||||
].includes(report.type);
|
||||
});
|
||||
return reports.filter(report =>
|
||||
ACTIVITY_METRICS_REPORTS.includes(report.type)
|
||||
);
|
||||
},
|
||||
|
||||
fetchDashboard() {
|
||||
|
||||
Reference in New Issue
Block a user