Switch to log base for the repo popularity

This commit is contained in:
Joseph Schorr 2015-07-22 14:20:46 -04:00
parent 2c29dc048d
commit 2ff1dfc8b7
2 changed files with 10 additions and 3 deletions

View file

@ -43,7 +43,8 @@
<span class="empty" ng-if="!repository.last_modified">(Empty Repository)</span>
</td>
<td class="popularity hidden-xs">
<span class="strength-indicator" value="repository.popularity" maximum="maxPopularity"></span>
<span class="strength-indicator" value="repository.popularity" maximum="maxPopularity"
log-base="10"></span>
</td>
<td>
<span class="repo-star" repository="repository"

View file

@ -10,7 +10,8 @@ angular.module('quay').directive('strengthIndicator', function () {
restrict: 'C',
scope: {
'value': '=value',
'maximum': '=maximum'
'maximum': '=maximum',
'logBase': '=logBase'
},
controller: function($scope, $element) {
$scope.strengthClass = '';
@ -22,8 +23,13 @@ angular.module('quay').directive('strengthIndicator', function () {
}
var value = Math.round(($scope.value / $scope.maximum) * 4);
if ($scope.logBase) {
var currentValue = Math.log($scope.value) / Math.log($scope.logBase * 1);
var maximum = Math.log($scope.maximum) / Math.log($scope.logBase * 1);
value = Math.round((currentValue / maximum) * 4);
}
if (value <= 0) {
if (value <= 0) {
$scope.strengthClass = 'none';
return;
}