mirror of
https://github.com/discourse/discourse.git
synced 2024-11-29 00:55:06 +08:00
8cf13977a1
A grab bag of smaller issues (constructor-super, no-fallthrough, ember/no-private-routing-service, no-unreachable, no-async-promise-executor)
59 lines
1.4 KiB
JavaScript
59 lines
1.4 KiB
JavaScript
import Mixin from "@ember/object/mixin";
|
|
import DiscourseURL from "discourse/lib/url";
|
|
import discourseComputed from "discourse-common/utils/decorators";
|
|
|
|
export default Mixin.create({
|
|
queryParams: ["period"],
|
|
period: "monthly",
|
|
|
|
init() {
|
|
this._super(...arguments);
|
|
|
|
this.availablePeriods = ["yearly", "quarterly", "monthly", "weekly"];
|
|
},
|
|
|
|
@discourseComputed("period")
|
|
startDate(period) {
|
|
const fullDay = moment().locale("en").utc().endOf("day");
|
|
|
|
switch (period) {
|
|
case "yearly":
|
|
return fullDay.subtract(1, "year").startOf("day");
|
|
case "quarterly":
|
|
return fullDay.subtract(3, "month").startOf("day");
|
|
case "weekly":
|
|
return fullDay.subtract(6, "days").startOf("day");
|
|
case "monthly":
|
|
return fullDay.subtract(1, "month").startOf("day");
|
|
default:
|
|
return fullDay.subtract(1, "month").startOf("day");
|
|
}
|
|
},
|
|
|
|
@discourseComputed()
|
|
lastWeek() {
|
|
return moment().locale("en").utc().endOf("day").subtract(1, "week");
|
|
},
|
|
|
|
@discourseComputed()
|
|
lastMonth() {
|
|
return moment().locale("en").utc().startOf("day").subtract(1, "month");
|
|
},
|
|
|
|
@discourseComputed()
|
|
endDate() {
|
|
return moment().locale("en").utc().endOf("day");
|
|
},
|
|
|
|
@discourseComputed()
|
|
today() {
|
|
return moment().locale("en").utc().endOf("day");
|
|
},
|
|
|
|
actions: {
|
|
changePeriod(period) {
|
|
DiscourseURL.routeTo(this._reportsForPeriodURL(period));
|
|
},
|
|
},
|
|
});
|