mirror of
https://github.com/discourse/discourse.git
synced 2025-06-05 22:24:47 +08:00
FIX: removes uncessary reports loading (#6119)
This commit is contained in:
@ -160,6 +160,52 @@ export default Ember.Component.extend({
|
|||||||
return `admin-report-${currentMode}`;
|
return `admin-report-${currentMode}`;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@computed("startDate")
|
||||||
|
normalizedStartDate(startDate) {
|
||||||
|
return startDate && typeof startDate.isValid === "function"
|
||||||
|
? startDate.format("YYYYMMDD")
|
||||||
|
: startDate;
|
||||||
|
},
|
||||||
|
|
||||||
|
@computed("endDate")
|
||||||
|
normalizedEndDate(endDate) {
|
||||||
|
return endDate && typeof endDate.isValid === "function"
|
||||||
|
? endDate.format("YYYYMMDD")
|
||||||
|
: endDate;
|
||||||
|
},
|
||||||
|
|
||||||
|
@computed(
|
||||||
|
"dataSourceName",
|
||||||
|
"categoryId",
|
||||||
|
"groupId",
|
||||||
|
"normalizedStartDate",
|
||||||
|
"normalizedEndDate"
|
||||||
|
)
|
||||||
|
reportKey(dataSourceName, categoryId, groupId, startDate, endDate) {
|
||||||
|
if (!dataSourceName || !startDate || !endDate) return null;
|
||||||
|
|
||||||
|
let reportKey = `reports:${dataSourceName}`;
|
||||||
|
|
||||||
|
if (categoryId && categoryId !== "all") {
|
||||||
|
reportKey += `:${categoryId}`;
|
||||||
|
} else {
|
||||||
|
reportKey += `:`;
|
||||||
|
}
|
||||||
|
|
||||||
|
reportKey += `:${startDate.replace(/-/g, "")}`;
|
||||||
|
reportKey += `:${endDate.replace(/-/g, "")}`;
|
||||||
|
|
||||||
|
if (groupId && groupId !== "all") {
|
||||||
|
reportKey += `:${groupId}`;
|
||||||
|
} else {
|
||||||
|
reportKey += `:`;
|
||||||
|
}
|
||||||
|
|
||||||
|
reportKey += `:`;
|
||||||
|
|
||||||
|
return reportKey;
|
||||||
|
},
|
||||||
|
|
||||||
actions: {
|
actions: {
|
||||||
exportCsv() {
|
exportCsv() {
|
||||||
exportEntity("report", {
|
exportEntity("report", {
|
||||||
@ -202,39 +248,10 @@ export default Ember.Component.extend({
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
let startDate = this.get("startDate");
|
if (!this.get("startDate") || !this.get("endDate")) {
|
||||||
let endDate = this.get("endDate");
|
|
||||||
|
|
||||||
startDate =
|
|
||||||
startDate && typeof startDate.isValid === "function"
|
|
||||||
? startDate.format("YYYYMMDD")
|
|
||||||
: startDate;
|
|
||||||
endDate =
|
|
||||||
startDate && typeof endDate.isValid === "function"
|
|
||||||
? endDate.format("YYYYMMDD")
|
|
||||||
: endDate;
|
|
||||||
|
|
||||||
if (!startDate || !endDate) {
|
|
||||||
report = sort(filteredReports)[0];
|
report = sort(filteredReports)[0];
|
||||||
} else {
|
} else {
|
||||||
let reportKey = `reports:${this.get("dataSourceName")}`;
|
let reportKey = this.get("reportKey");
|
||||||
|
|
||||||
if (this.get("categoryId") && this.get("categoryId") !== "all") {
|
|
||||||
reportKey += `:${this.get("categoryId")}`;
|
|
||||||
} else {
|
|
||||||
reportKey += `:`;
|
|
||||||
}
|
|
||||||
|
|
||||||
reportKey += `:${startDate.replace(/-/g, "")}`;
|
|
||||||
reportKey += `:${endDate.replace(/-/g, "")}`;
|
|
||||||
|
|
||||||
if (this.get("groupId") && this.get("groupId") !== "all") {
|
|
||||||
reportKey += `:${this.get("groupId")}`;
|
|
||||||
} else {
|
|
||||||
reportKey += `:`;
|
|
||||||
}
|
|
||||||
|
|
||||||
reportKey += `:`;
|
|
||||||
|
|
||||||
report = sort(
|
report = sort(
|
||||||
filteredReports.filter(r => r.report_key.includes(reportKey))
|
filteredReports.filter(r => r.report_key.includes(reportKey))
|
||||||
|
@ -4,6 +4,28 @@ import AdminDashboardNext from "admin/models/admin-dashboard-next";
|
|||||||
import Report from "admin/models/report";
|
import Report from "admin/models/report";
|
||||||
import PeriodComputationMixin from "admin/mixins/period-computation";
|
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, {
|
export default Ember.Controller.extend(PeriodComputationMixin, {
|
||||||
isLoading: false,
|
isLoading: false,
|
||||||
dashboardFetchedAt: null,
|
dashboardFetchedAt: null,
|
||||||
@ -25,38 +47,23 @@ export default Ember.Controller.extend(PeriodComputationMixin, {
|
|||||||
return { table: { total: false, limit: 8 } };
|
return { table: { total: false, limit: 8 } };
|
||||||
},
|
},
|
||||||
|
|
||||||
@computed("reports.[]")
|
signupsReport: dynamicReport("signups"),
|
||||||
topReferredTopicsReport(reports) {
|
topicsReport: dynamicReport("topics"),
|
||||||
return reports.find(x => x.type === "top_referred_topics");
|
postsReport: dynamicReport("posts"),
|
||||||
},
|
dauByMauReport: dynamicReport("dau_by_mau"),
|
||||||
|
dailyEngagedUsersReport: dynamicReport("daily_engaged_users"),
|
||||||
|
newContributorsReport: dynamicReport("new_contributors"),
|
||||||
|
|
||||||
@computed("reports.[]")
|
topReferredTopicsReport: staticReport("top_referred_topics"),
|
||||||
trendingSearchReport(reports) {
|
trendingSearchReport: staticReport("trending_search"),
|
||||||
return reports.find(x => x.type === "trending_search");
|
usersByTypeReport: staticReport("users_by_type"),
|
||||||
},
|
usersByTrustLevelReport: staticReport("users_by_trust_level"),
|
||||||
|
|
||||||
@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");
|
|
||||||
},
|
|
||||||
|
|
||||||
@computed("reports.[]")
|
@computed("reports.[]")
|
||||||
activityMetricsReports(reports) {
|
activityMetricsReports(reports) {
|
||||||
return reports.filter(report => {
|
return reports.filter(report =>
|
||||||
return [
|
ACTIVITY_METRICS_REPORTS.includes(report.type)
|
||||||
"page_view_total_reqs",
|
);
|
||||||
"visits",
|
|
||||||
"time_to_first_response",
|
|
||||||
"likes",
|
|
||||||
"flags",
|
|
||||||
"user_to_user_private_messages_with_replies"
|
|
||||||
].includes(report.type);
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
|
|
||||||
fetchDashboard() {
|
fetchDashboard() {
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
<div class="charts">
|
<div class="charts">
|
||||||
{{admin-report
|
{{admin-report
|
||||||
dataSourceName="signups"
|
dataSourceName="signups"
|
||||||
|
report=signupsReport
|
||||||
showTrend=true
|
showTrend=true
|
||||||
forcedModes="chart"
|
forcedModes="chart"
|
||||||
startDate=startDate
|
startDate=startDate
|
||||||
@ -19,6 +20,7 @@
|
|||||||
|
|
||||||
{{admin-report
|
{{admin-report
|
||||||
dataSourceName="topics"
|
dataSourceName="topics"
|
||||||
|
report=topicsReport
|
||||||
showTrend=true
|
showTrend=true
|
||||||
forcedModes="chart"
|
forcedModes="chart"
|
||||||
startDate=startDate
|
startDate=startDate
|
||||||
@ -26,6 +28,7 @@
|
|||||||
|
|
||||||
{{admin-report
|
{{admin-report
|
||||||
dataSourceName="posts"
|
dataSourceName="posts"
|
||||||
|
report=postsReport
|
||||||
showTrend=true
|
showTrend=true
|
||||||
forcedModes="chart"
|
forcedModes="chart"
|
||||||
startDate=startDate
|
startDate=startDate
|
||||||
@ -33,6 +36,7 @@
|
|||||||
|
|
||||||
{{admin-report
|
{{admin-report
|
||||||
dataSourceName="dau_by_mau"
|
dataSourceName="dau_by_mau"
|
||||||
|
report=dauByMauReport
|
||||||
showTrend=true
|
showTrend=true
|
||||||
forcedModes="chart"
|
forcedModes="chart"
|
||||||
startDate=startDate
|
startDate=startDate
|
||||||
@ -40,6 +44,7 @@
|
|||||||
|
|
||||||
{{admin-report
|
{{admin-report
|
||||||
dataSourceName="daily_engaged_users"
|
dataSourceName="daily_engaged_users"
|
||||||
|
report=dailyEngagedUsersReport
|
||||||
showTrend=true
|
showTrend=true
|
||||||
forcedModes="chart"
|
forcedModes="chart"
|
||||||
startDate=startDate
|
startDate=startDate
|
||||||
@ -47,6 +52,7 @@
|
|||||||
|
|
||||||
{{admin-report
|
{{admin-report
|
||||||
dataSourceName="new_contributors"
|
dataSourceName="new_contributors"
|
||||||
|
report=newContributorsReport
|
||||||
showTrend=true
|
showTrend=true
|
||||||
forcedModes="chart"
|
forcedModes="chart"
|
||||||
startDate=startDate
|
startDate=startDate
|
||||||
|
@ -1,6 +1,12 @@
|
|||||||
class AdminDashboardNextGeneralData < AdminDashboardNextData
|
class AdminDashboardNextGeneralData < AdminDashboardNextData
|
||||||
def reports
|
def reports
|
||||||
@reports ||= %w{
|
@reports ||= %w{
|
||||||
|
signups
|
||||||
|
topics
|
||||||
|
posts
|
||||||
|
dau_by_mau
|
||||||
|
daily_engaged_users
|
||||||
|
new_contributors
|
||||||
page_view_total_reqs
|
page_view_total_reqs
|
||||||
visits
|
visits
|
||||||
time_to_first_response
|
time_to_first_response
|
||||||
|
Reference in New Issue
Block a user