mirror of
https://github.com/discourse/discourse.git
synced 2024-11-26 14:13:38 +08:00
FIX: makes dashboard periods use current day and weekly 7 days (#10817)
Prior to this fix, weekly could be 8 days and we could have differences between period chooser text and actual results in the chart. A good followup to this PR would be to add custom date ranges in period-chooser component.
This commit is contained in:
parent
4b5358bb42
commit
702f7a5a67
|
@ -14,7 +14,7 @@ export default Mixin.create({
|
||||||
|
|
||||||
@discourseComputed("period")
|
@discourseComputed("period")
|
||||||
startDate(period) {
|
startDate(period) {
|
||||||
let fullDay = moment().locale("en").utc().subtract(1, "day");
|
let fullDay = moment().locale("en").utc().endOf("day");
|
||||||
|
|
||||||
switch (period) {
|
switch (period) {
|
||||||
case "yearly":
|
case "yearly":
|
||||||
|
@ -24,7 +24,7 @@ export default Mixin.create({
|
||||||
return fullDay.subtract(3, "month").startOf("day");
|
return fullDay.subtract(3, "month").startOf("day");
|
||||||
break;
|
break;
|
||||||
case "weekly":
|
case "weekly":
|
||||||
return fullDay.subtract(1, "week").startOf("day");
|
return fullDay.subtract(6, "days").startOf("day");
|
||||||
break;
|
break;
|
||||||
case "monthly":
|
case "monthly":
|
||||||
return fullDay.subtract(1, "month").startOf("day");
|
return fullDay.subtract(1, "month").startOf("day");
|
||||||
|
@ -46,7 +46,7 @@ export default Mixin.create({
|
||||||
|
|
||||||
@discourseComputed()
|
@discourseComputed()
|
||||||
endDate() {
|
endDate() {
|
||||||
return moment().locale("en").utc().subtract(1, "day").endOf("day");
|
return moment().locale("en").utc().endOf("day");
|
||||||
},
|
},
|
||||||
|
|
||||||
@discourseComputed()
|
@discourseComputed()
|
||||||
|
|
|
@ -10,7 +10,11 @@
|
||||||
{{i18n "admin.dashboard.community_health"}}
|
{{i18n "admin.dashboard.community_health"}}
|
||||||
</a>
|
</a>
|
||||||
</h2>
|
</h2>
|
||||||
{{period-chooser period=period action=(action "changePeriod") content=availablePeriods fullDay=true}}
|
{{period-chooser
|
||||||
|
period=period
|
||||||
|
action=(action "changePeriod")
|
||||||
|
content=availablePeriods
|
||||||
|
fullDay=false}}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="section-body">
|
<div class="section-body">
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
period=period
|
period=period
|
||||||
action=(action "changePeriod")
|
action=(action "changePeriod")
|
||||||
content=availablePeriods
|
content=availablePeriods
|
||||||
fullDay=true}}
|
fullDay=false}}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="section-body">
|
<div class="section-body">
|
||||||
|
|
|
@ -12,7 +12,7 @@ const TITLE_SUBS = {
|
||||||
export default htmlHelper((period, options) => {
|
export default htmlHelper((period, options) => {
|
||||||
const title = I18n.t("filters.top." + (TITLE_SUBS[period] || "this_week"));
|
const title = I18n.t("filters.top." + (TITLE_SUBS[period] || "this_week"));
|
||||||
if (options.hash.showDateRange) {
|
if (options.hash.showDateRange) {
|
||||||
var dateString = "";
|
let dateString = "";
|
||||||
let finish;
|
let finish;
|
||||||
|
|
||||||
if (options.hash.fullDay) {
|
if (options.hash.fullDay) {
|
||||||
|
@ -41,11 +41,15 @@ export default htmlHelper((period, options) => {
|
||||||
finish.format(I18n.t("dates.long_no_year_no_time"));
|
finish.format(I18n.t("dates.long_no_year_no_time"));
|
||||||
break;
|
break;
|
||||||
case "weekly":
|
case "weekly":
|
||||||
|
let start;
|
||||||
|
if (options.hash.fullDay) {
|
||||||
|
start = finish.clone().subtract(1, "week");
|
||||||
|
} else {
|
||||||
|
start = finish.clone().subtract(6, "days");
|
||||||
|
}
|
||||||
|
|
||||||
dateString =
|
dateString =
|
||||||
finish
|
start.format(I18n.t("dates.long_no_year_no_time")) +
|
||||||
.clone()
|
|
||||||
.subtract(1, "week")
|
|
||||||
.format(I18n.t("dates.long_no_year_no_time")) +
|
|
||||||
" - " +
|
" - " +
|
||||||
finish.format(I18n.t("dates.long_no_year_no_time"));
|
finish.format(I18n.t("dates.long_no_year_no_time"));
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user