FIX: counters were showing future instead of past (#6299)

This commit is contained in:
Joffrey JAFFEUX 2018-08-22 12:37:05 +02:00 committed by GitHub
parent 599cebf8ad
commit 87d443f070
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 139 additions and 1 deletions

View File

@ -40,6 +40,14 @@ export default Ember.Controller.extend(PeriodComputationMixin, {
];
},
@computed
activityMetricsFilters() {
return {
startDate: this.get("lastMonth"),
endDate: this.get("today")
};
},
@computed
trendingSearchOptions() {
return { table: { total: false, limit: 8 } };

View File

@ -42,6 +42,15 @@ export default Ember.Mixin.create({
.subtract(1, "week");
},
@computed()
lastMonth() {
return moment()
.locale("en")
.utc()
.startOf("day")
.subtract(1, "month");
},
@computed()
endDate() {
return moment()
@ -51,6 +60,14 @@ export default Ember.Mixin.create({
.endOf("day");
},
@computed()
today() {
return moment()
.locale("en")
.utc()
.endOf("day");
},
actions: {
changePeriod(period) {
DiscourseURL.routeTo(this._reportsForPeriodURL(period));

View File

@ -79,6 +79,7 @@
{{#each activityMetrics as |metric|}}
{{admin-report
showHeader=false
filters=activityMetricsFilters
forcedModes="counters"
dataSourceName=metric}}
{{/each}}

View File

@ -29,3 +29,32 @@ QUnit.test("Visit dashboard next page", async assert => {
"displays problems"
);
});
QUnit.test("it has counters", async assert => {
await visit("/admin");
assert.equal(
$(".admin-report.page-view-total-reqs .today-count")
.text()
.trim(),
"1.1k"
);
assert.equal(
$(".admin-report.page-view-total-reqs .yesterday-count")
.text()
.trim(),
"2.5k"
);
assert.equal(
$(".admin-report.page-view-total-reqs .sevendays-count")
.text()
.trim(),
"18.6k"
);
assert.equal(
$(".admin-report.page-view-total-reqs .thirty-days-count")
.text()
.trim(),
"80.8k"
);
});

View File

@ -1,7 +1,90 @@
const startDate = moment()
.locale("en")
.utc()
.startOf("day")
.subtract(1, "month");
const endDate = moment()
.locale("en")
.utc()
.endOf("day");
const data = [
851,
3805,
2437,
3768,
4476,
3021,
1285,
1120,
3932,
2777,
3298,
3198,
3601,
1249,
1046,
3212,
3358,
3306,
2618,
2679,
910,
875,
3877,
2342,
2305,
3534,
3713,
1133,
1350,
4048,
2523,
1062
];
export default {
"/admin/reports/page_view_total_reqs": {
report: {
report_key: "page_view_total_reqs"
type: "page_view_total_reqs",
title: "Pageviews",
xaxis: "Day",
yaxis: "Total Pageviews",
description: null,
data: [...data].map((d, i) => {
return {
x: moment(startDate)
.add(i, "days")
.format("YYYY-MM-DD"),
y: d
};
}),
start_date: startDate.toISOString(),
end_date: endDate.toISOString(),
prev_data: null,
prev_start_date: "2018-06-20T00:00:00Z",
prev_end_date: "2018-07-23T00:00:00Z",
category_id: null,
group_id: null,
prev30Days: 58110,
dates_filtering: true,
report_key: `reports:page_view_total_reqs:${startDate.format(
"YYYYMMDD"
)}:${endDate.format("YYYYMMDD")}:[:prev_period]:2`,
labels: [
{ type: "date", property: "x", title: "Day" },
{ type: "number", property: "y", title: "Count" }
],
processing: false,
average: false,
percent: false,
higher_is_better: true,
category_filtering: false,
group_filtering: false,
modes: ["table", "chart"],
icon: "file",
total: 921672
}
}
};