🐛Fix admin analytics date bugs

This commit is contained in:
Matt Lott 2015-11-10 17:26:13 -08:00
parent d9d5dce2e0
commit 1c0550ff9f
2 changed files with 10 additions and 4 deletions

View file

@ -1,11 +1,12 @@
# 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
days = []
currentDate = new Date()
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)
days.push(currentDay)
currentDate.setUTCDate(currentDate.getUTCDate() + 1)

View file

@ -119,9 +119,14 @@ module.exports = class AnalyticsView extends RootView
points = []
for entry, i in data
points.push
x: i
y: entry.value
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
for day, i in days