correct daily engaged users to look at average

This commit is contained in:
Sam 2018-05-15 10:17:17 +10:00
parent a28c58feb1
commit eb33f6e9b9
5 changed files with 15 additions and 4 deletions

View File

@ -33,6 +33,7 @@ export default Ember.Component.extend(AsyncReport, {
backgroundColor: "rgba(200,220,240,0.3)",
borderColor: "#08C",
average: false,
percent: false,
total: 0,
@computed("dataSourceName")
@ -142,6 +143,7 @@ export default Ember.Component.extend(AsyncReport, {
this.get("startDate").isSame(this.get("endDate"), "day");
report.set("average", this.get("average"));
report.set("percent", this.get("percent"));
this.setProperties({ oneDataPoint, report });
},

View File

@ -177,8 +177,10 @@ const Report = Discourse.Model.extend({
if (this.get('average')) {
prev = prev ? prev.toFixed(1) : "0";
current += '%';
prev += '%';
if (this.get('percent')) {
current += '%';
prev += '%';
}
}
return I18n.t('admin.dashboard.reports.trend_title', {percent: percent, prev: prev, current: current});

View File

@ -9,7 +9,7 @@
<div class="chart-trend {{trend}}">
{{#if average}}
<span title="{{report.trendTitle}}">
{{report.currentAverage}}%
{{report.currentAverage}}{{if percent "%"}}
</span>
{{else}}
<span title="{{report.trendTitle}}">

View File

@ -38,11 +38,13 @@
{{dashboard-mini-chart
dataSourceName="dau_by_mau"
average=true
percent=true
startDate=startDate
endDate=endDate}}
{{dashboard-mini-chart
dataSourceName="daily_engaged_users"
average=true
startDate=startDate
endDate=endDate}}

View File

@ -188,7 +188,12 @@ class Report
if report.facets.include?(:prev_period)
prev_data = UserAction.count_daily_engaged_users(report.start_date - (report.end_date - report.start_date), report.start_date)
report.prev_period = prev_data.sum { |k, v| v }
prev = prev_data.sum { |k, v| v }
if prev > 0
prev = prev / ((report.end_date - report.start_date) / 1.day)
end
report.prev_period = prev
end
data.each do |key, value|