MCPcopy Create free account
hub / github.com/codecombat/codecombat / updateKPIChartData

Method updateKPIChartData

app/views/admin/AnalyticsView.js:850–1086  ·  view source on GitHub ↗
(timeframeDays, chartLines)

Source from the content-addressed store, hash-verified

848 }
849
850 updateKPIChartData (timeframeDays, chartLines) {
851 let campaignData, count, data, day, days, entry, event, eventDayDataMap, pointRadius, points, value
852 if (timeframeDays === 365) {
853 // Add previous year too
854 days = d3Utils.createContiguousDays(timeframeDays, true, 365)
855 pointRadius = 0.5
856
857 // Build active classes KPI line
858 if ((this.activeClasses != null ? this.activeClasses.length : undefined) > 0) {
859 data = []
860 for (entry of Array.from(this.activeClasses)) {
861 data.push({
862 day: entry.day,
863 value: entry.groups[entry.groups.length - 1]
864 })
865 }
866 data.reverse()
867 points = this.createLineChartPoints(days, data)
868 chartLines.push({
869 points,
870 description: 'Monthly Active Classes (last year)',
871 lineColor: 'lightskyblue',
872 strokeWidth: 1,
873 min: 0,
874 max: _.max(points, 'y').y,
875 showYScale: false,
876 pointRadius
877 })
878 }
879
880 // Build recurring revenue KPI line
881 if ((this.revenue != null ? this.revenue.length : undefined) > 0) {
882 data = []
883 for (entry of Array.from(this.revenue)) {
884 value = this.dayMrrMap[entry.day]
885 data.push({
886 day: entry.day,
887 value: value / 100 / 1000
888 })
889 }
890 data.reverse()
891 points = this.createLineChartPoints(days, data)
892 chartLines.push({
893 points,
894 description: 'Monthly Recurring Revenue (in thousands) (last year)',
895 lineColor: 'mediumseagreen',
896 strokeWidth: 1,
897 min: 0,
898 max: _.max(points, 'y').y,
899 showYScale: false,
900 pointRadius
901 })
902 }
903
904 // Build campaign MAU KPI line
905 if ((this.activeUsers != null ? this.activeUsers.length : undefined) > 0) {
906 eventDayDataMap = {}
907 for (entry of Array.from(this.activeUsers)) {

Callers 1

updateAllKPIChartDataMethod · 0.95

Calls 1

createLineChartPointsMethod · 0.95

Tested by

no test coverage detected