mirror of
https://github.com/discourse/discourse.git
synced 2024-11-27 16:33:37 +08:00
FIX: counters were showing future instead of past (#6299)
This commit is contained in:
parent
599cebf8ad
commit
87d443f070
|
@ -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 } };
|
||||
|
|
|
@ -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));
|
||||
|
|
|
@ -79,6 +79,7 @@
|
|||
{{#each activityMetrics as |metric|}}
|
||||
{{admin-report
|
||||
showHeader=false
|
||||
filters=activityMetricsFilters
|
||||
forcedModes="counters"
|
||||
dataSourceName=metric}}
|
||||
{{/each}}
|
||||
|
|
|
@ -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"
|
||||
);
|
||||
});
|
||||
|
|
|
@ -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
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue
Block a user