🐛Fix admin analytics date bugs
This commit is contained in:
parent
d9d5dce2e0
commit
1c0550ff9f
2 changed files with 10 additions and 4 deletions
app
|
@ -1,11 +1,12 @@
|
||||||
# Caller needs require 'vendor/d3'
|
# Caller needs require 'vendor/d3'
|
||||||
|
|
||||||
module.exports.createContiguousDays = (timeframeDays) ->
|
module.exports.createContiguousDays = (timeframeDays, skipToday=true) ->
|
||||||
# Return list of last 'timeframeDays' contiguous days in yyyy-mm-dd format
|
# Return list of last 'timeframeDays' contiguous days in yyyy-mm-dd format
|
||||||
days = []
|
days = []
|
||||||
currentDate = new Date()
|
currentDate = new Date()
|
||||||
currentDate.setUTCDate(currentDate.getUTCDate() - timeframeDays)
|
currentDate.setUTCDate(currentDate.getUTCDate() - timeframeDays)
|
||||||
for i in [0..timeframeDays]
|
currentDate.setUTCDate(currentDate.getUTCDate() - 1) if skipToday
|
||||||
|
for i in [0...timeframeDays]
|
||||||
currentDay = currentDate.toISOString().substr(0, 10)
|
currentDay = currentDate.toISOString().substr(0, 10)
|
||||||
days.push(currentDay)
|
days.push(currentDay)
|
||||||
currentDate.setUTCDate(currentDate.getUTCDate() + 1)
|
currentDate.setUTCDate(currentDate.getUTCDate() + 1)
|
||||||
|
|
|
@ -119,9 +119,14 @@ module.exports = class AnalyticsView extends RootView
|
||||||
points = []
|
points = []
|
||||||
for entry, i in data
|
for entry, i in data
|
||||||
points.push
|
points.push
|
||||||
x: i
|
|
||||||
y: entry.value
|
|
||||||
day: entry.day
|
day: entry.day
|
||||||
|
y: entry.value
|
||||||
|
|
||||||
|
# Trim points preceding days
|
||||||
|
for point, i in points
|
||||||
|
if point.day is days[0]
|
||||||
|
points.splice(0, i)
|
||||||
|
break
|
||||||
|
|
||||||
# Ensure points for each day
|
# Ensure points for each day
|
||||||
for day, i in days
|
for day, i in days
|
||||||
|
|
Reference in a new issue