-
-
Save dievardump/89fd5a6da129cfa7dcf6 to your computer and use it in GitHub Desktop.
7:15pm, on wednesday, after have already done more than 35 hours this week, I check the freelance code...
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
_setMetricsCalculation: function(minMax) { | |
var total = {fans:0, corporate_posts:0, corporate_comments:0, likes:0, comments:0, shares:0, user_posts:0}; | |
var row = 0; | |
_.each(this._channels, function(channel, index) { | |
row = index + 1; | |
total.fans += NumberUtils.int(channel.fans); | |
total.corporate_posts += NumberUtils.int(channel.corporate_posts); | |
total.corporate_comments += NumberUtils.int(channel.corporate_comments); | |
total.likes += NumberUtils.int(channel.likes); | |
total.comments += NumberUtils.int(channel.comments); | |
total.shares += NumberUtils.int(channel.shares); | |
total.user_posts += NumberUtils.int(channel.user_posts); | |
// Fans min/max | |
if(minMax.fans.min.id == channel.id && !channel.selected) | |
this._setMinMaxCustomStyle(row, 2, 'min'); | |
if(minMax.fans.max.id == channel.id && !channel.selected) | |
this._setMinMaxCustomStyle(row, 2, 'max'); | |
// Admin posts min/max | |
if(minMax.corporate_posts.min.id == channel.id && !channel.selected) | |
this._setMinMaxCustomStyle(row, 3, 'min'); | |
if(minMax.corporate_posts.max.id == channel.id && !channel.selected) | |
this._setMinMaxCustomStyle(row, 3, 'max'); | |
// Admin comments min/max | |
if(minMax.corporate_comments.min.id == channel.id && !channel.selected) | |
this._setMinMaxCustomStyle(row, 4, 'min'); | |
if(minMax.corporate_comments.max.id == channel.id && !channel.selected) | |
this._setMinMaxCustomStyle(row, 4, 'max'); | |
// Likes min/max | |
if(minMax.likes.min.id == channel.id && !channel.selected) | |
this._setMinMaxCustomStyle(row, 5, 'min'); | |
if(minMax.likes.max.id == channel.id && !channel.selected) | |
this._setMinMaxCustomStyle(row, 5, 'max'); | |
// Comments min/max | |
if(minMax.comments.min.id == channel.id && !channel.selected) | |
this._setMinMaxCustomStyle(row, 6, 'min'); | |
if(minMax.comments.max.id == channel.id && !channel.selected) | |
this._setMinMaxCustomStyle(row, 6, 'max'); | |
// Shares min/max | |
if(minMax.shares.min.id == channel.id && !channel.selected) | |
this._setMinMaxCustomStyle(row, 7, 'min'); | |
if(minMax.shares.max.id == channel.id && !channel.selected) | |
this._setMinMaxCustomStyle(row, 7, 'max'); | |
// User posts min/max | |
if(minMax.user_posts.min.id == channel.id && !channel.selected) | |
this._setMinMaxCustomStyle(row, 8, 'min'); | |
if(minMax.user_posts.max.id == channel.id && !channel.selected) | |
this._setMinMaxCustomStyle(row, 8, 'max'); | |
}, this); | |
var numberOfRows = row > 0 ? row : 1; | |
// Group average data | |
row +=1; | |
var groupAvgEl = $('.snapshot-data-table table tbody tr:nth-child(' + row + ')'); | |
$(groupAvgEl.children()[0]).addClass('average-header'); | |
$(groupAvgEl.children()[1]).addClass('average-value').html(Math.round(total.fans/numberOfRows)); | |
$(groupAvgEl.children()[2]).addClass('average-value').html(Math.round(total.corporate_posts/numberOfRows)); | |
$(groupAvgEl.children()[3]).addClass('average-value').html(Math.round(total.corporate_comments/numberOfRows)); | |
$(groupAvgEl.children()[4]).addClass('average-value').html(Math.round(total.likes/numberOfRows)); | |
$(groupAvgEl.children()[5]).addClass('average-value').html(Math.round(total.comments/numberOfRows)); | |
$(groupAvgEl.children()[6]).addClass('average-value').html(Math.round(total.shares/numberOfRows)); | |
$(groupAvgEl.children()[7]).addClass('average-value').html(Math.round(total.user_posts/numberOfRows)); | |
// Benchmark average data | |
row +=1; | |
var benchAvgEl = $('.snapshot-data-table table tbody tr:nth-child(' + row + ')'); | |
$(benchAvgEl.children()[0]).addClass('average-header'); | |
$(benchAvgEl.children()[1]).addClass('average-value').html(this._benchmarkModel.metric().data().fans); | |
$(benchAvgEl.children()[2]).addClass('average-value').html(this._benchmarkModel.metric().data().corporate_posts); | |
$(benchAvgEl.children()[3]).addClass('average-value').html(this._benchmarkModel.metric().data().corporate_comments); | |
$(benchAvgEl.children()[4]).addClass('average-value').html(this._benchmarkModel.metric().data().likes); | |
$(benchAvgEl.children()[5]).addClass('average-value').html(this._benchmarkModel.metric().data().comments); | |
$(benchAvgEl.children()[6]).addClass('average-value').html(this._benchmarkModel.metric().data().shares); | |
$(benchAvgEl.children()[7]).addClass('average-value').html(this._benchmarkModel.metric().data().user_posts); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment