Mark top3 and bottom3 levels in campaign analytics

This commit is contained in:
Matt Lott 2015-01-15 15:19:16 -08:00
parent e499678223
commit e67532cf5d
2 changed files with 12 additions and 1 deletions

View file

@ -68,6 +68,11 @@ block outer_content
td= campaignCompletions.levels[i].level td= campaignCompletions.levels[i].level
td= campaignCompletions.levels[i].started td= campaignCompletions.levels[i].started
td= campaignCompletions.levels[i].finished td= campaignCompletions.levels[i].finished
if campaignCompletions.top3.indexOf(campaignCompletions.levels[i].level) >= 0
td(style='background-color:lightblue;')= campaignCompletions.levels[i].completionRate
else if campaignCompletions.bottom3.indexOf(campaignCompletions.levels[i].level) >= 0
td(style='background-color:pink;')= campaignCompletions.levels[i].completionRate
else
td= campaignCompletions.levels[i].completionRate td= campaignCompletions.levels[i].completionRate
else else
button.btn.btn-default.disabled#analytics-button Analytics Loading... button.btn.btn-default.disabled#analytics-button Analytics Loading...

View file

@ -252,6 +252,12 @@ module.exports = class CampaignEditorView extends RootView
item.completionRate = (item.finished / item.started * 100).toFixed(2) item.completionRate = (item.finished / item.started * 100).toFixed(2)
item item
@campaignCompletions = levels: _.map data, mapFn, @ @campaignCompletions = levels: _.map data, mapFn, @
sortedLevels = _.cloneDeep @campaignCompletions.levels
sortedLevels = _.filter sortedLevels, ((a) -> a.completionRate > 1.0), @
sortedLevels.sort (a, b) -> b.completionRate - a.completionRate
@campaignCompletions.top3 = _.pluck sortedLevels[0..2], 'level'
sortedLevels.sort (a, b) -> a.completionRate - b.completionRate
@campaignCompletions.bottom3 = _.pluck sortedLevels[0..2], 'level'
@campaignCompletions.startDay = "#{startDay[0..3]}-#{startDay[4..5]}-#{startDay[6..7]}" @campaignCompletions.startDay = "#{startDay[0..3]}-#{startDay[4..5]}-#{startDay[6..7]}"
@campaignCompletions.endDay = "#{endDay[0..3]}-#{endDay[4..5]}-#{endDay[6..7]}" @campaignCompletions.endDay = "#{endDay[0..3]}-#{endDay[4..5]}-#{endDay[6..7]}"
@render() @render()