mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2025-03-13 22:49:51 -04:00
🐛Fix admin analytics date bugs
This commit is contained in:
parent
d9d5dce2e0
commit
1c0550ff9f
2 changed files with 10 additions and 4 deletions
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue