Skip to content

Commit

Permalink
fix: redefine dates logic
Browse files Browse the repository at this point in the history
  • Loading branch information
mjatin-dev committed Mar 4, 2022
1 parent 45bf399 commit fc882ec
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
4 changes: 2 additions & 2 deletions admin-ui/app/routes/Dashboards/DashboardPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@ function DashboardPage({ statData, permissions, clients, loading, dispatch }) {

function generateDateRange(start, end) {
var result = []
while (start.isBefore(end)) {
result.push(start.format('YYYY-MM-01'))
while (end > start || start.format('M') === end.format('M')) {
result.push(start.format('YYYY-MM') + '-01')
start.add(1, 'month')
}
return result
Expand Down
7 changes: 3 additions & 4 deletions admin-ui/plugins/admin/components/MAU/MauGraph.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,6 @@ function MauGraph({ statData, permissions, clients, loading, dispatch }) {
if (stat && stat.length >= 1) {
let flattendStat = stat.map((entry) => entry['month'])
let aRange = generateDateRange(moment(startDate), moment(endDate))
console.log(moment(startDate).format())
console.log(moment(endDate).format())
for (const ele of aRange) {
const currentMonth = getYearMonth(new Date(ele))
if (flattendStat.indexOf(parseInt(currentMonth, 10)) === -1) {
Expand Down Expand Up @@ -99,8 +97,9 @@ function MauGraph({ statData, permissions, clients, loading, dispatch }) {

function generateDateRange(start, end) {
var result = []
while (start.isBefore(end)) {
result.push(start.format('YYYY-MM-01'))

while (end > start || start.format('M') === end.format('M')) {
result.push(start.format('YYYY-MM') + '-01')
start.add(1, 'month')
}
return result
Expand Down

0 comments on commit fc882ec

Please sign in to comment.