mirror of
https://github.com/taobataoma/meanTorrent.git
synced 2026-01-24 16:19:20 +01:00
feat(collections): show collection Vote average
This commit is contained in:
@@ -29,10 +29,23 @@
|
||||
collectionId: $state.params.collectionId
|
||||
}, function (data) {
|
||||
vm.collection = data;
|
||||
mtDebug.info(data);
|
||||
|
||||
$('.backdrop').css('backgroundImage', 'url("' + vm.tmdbConfig.backdropImgBaseUrl + vm.collection.backdrop_path + '")');
|
||||
//vm.buildPager();
|
||||
|
||||
//count ave vote
|
||||
var total = 0;
|
||||
var count = 0;
|
||||
var total_users = 0;
|
||||
angular.forEach(vm.collection.torrents, function(t){
|
||||
total += t.resource_detail_info.vote_average;
|
||||
count += 1;
|
||||
total_users += t.resource_detail_info.vote_count;
|
||||
});
|
||||
|
||||
vm.collection.vote_count = total_users;
|
||||
vm.collection.vote_average = Math.floor((total / count) * 10) / 10;
|
||||
|
||||
mtDebug.info(vm.collection);
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
@@ -59,6 +59,24 @@
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* getVoteAverage
|
||||
* @param c
|
||||
* @returns {number}
|
||||
*/
|
||||
vm.getVoteAverage = function (c) {
|
||||
var total = 0;
|
||||
var count = 0;
|
||||
var avg = 0;
|
||||
|
||||
angular.forEach(c.torrents, function (t) {
|
||||
total += t.resource_detail_info.vote_average;
|
||||
count += 1;
|
||||
});
|
||||
avg = Math.floor((total / count) * 10) / 10;
|
||||
|
||||
return avg || 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* pageChanged
|
||||
|
||||
@@ -12,8 +12,11 @@
|
||||
</div>
|
||||
<div class="col-sm-12">
|
||||
<ul class="list-unstyled item-data list-inline">
|
||||
<li><i class="fa fa-list text-info"> {{'COLLECTIONS.FILES_NUMBERS' | translate}}: {{vm.collection.torrents.length}}</i></li>
|
||||
<li><i class="fa fa-star-half-o text-info"> {{'COLLECTIONS.VOTE_AVERAGE' | translate}}: 0</i></li>
|
||||
<li><i class="fa fa-list text-info"> {{'COLLECTIONS.FILES_NUMBERS' | translate}}: {{vm.collection.torrents.length}}</i>
|
||||
</li>
|
||||
<li><i class="fa fa-star-half-o text-info"> {{'COLLECTIONS.VOTE_AVERAGE' | translate}}:
|
||||
{{vm.collection.vote_average}} / {{vm.collection.vote_count}} {{ 'TMDB_FIELDS.VOTE_UNIT' | translate}}
|
||||
</i></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -42,7 +42,7 @@
|
||||
</div>
|
||||
<div class="col-xs-6 col-small-padding text-center">
|
||||
<i class="fa fa-star-half-o text-info">
|
||||
<strong> {{'COLLECTIONS.VOTE_AVERAGE' | translate}}: {{m.torrents.length}}</strong></i>
|
||||
<strong> {{'COLLECTIONS.VOTE_AVERAGE' | translate}}: {{vm.getVoteAverage(m);}}</strong></i>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user