Make repo pull and push counts on the info page be abbreviated

This commit is contained in:
Joseph Schorr 2015-04-27 14:43:55 -04:00
parent 1979f87384
commit be9906167a
2 changed files with 30 additions and 4 deletions

View file

@ -6,12 +6,12 @@
<div class="stat-title">Repo Pulls</div>
<div class="stat">
<div class="stat-value">{{ repository.stats.pulls.today }}</div>
<div class="stat-value">{{ repository.stats.pulls.today | abbreviated }}</div>
<div class="stat-subtitle">Last 24 hours</div>
</div>
<div class="stat">
<div class="stat-value">{{ repository.stats.pulls.thirty_day }}</div>
<div class="stat-value">{{ repository.stats.pulls.thirty_day | abbreviated }}</div>
<div class="stat-subtitle">Last 30 days</div>
</div>
</div>
@ -21,12 +21,12 @@
<div class="stat-title">Repo Pushes</div>
<div class="stat">
<div class="stat-value">{{ repository.stats.pushes.today }}</div>
<div class="stat-value">{{ repository.stats.pushes.today | abbreviated }}</div>
<div class="stat-subtitle">Last 24 hours</div>
</div>
<div class="stat">
<div class="stat-value">{{ repository.stats.pushes.thirty_day }}</div>
<div class="stat-value">{{ repository.stats.pushes.thirty_day | abbreviated }}</div>
<div class="stat-subtitle">Last 30 days</div>
</div>
</div>

View file

@ -0,0 +1,26 @@
/**
* Filter which displays numbers with suffixes.
*
* Based on: https://gist.github.com/pedrorocha-net/9aa21d5f34d9cc15d18f
*/
angular.module('quay').filter('abbreviated', function() {
return function(number) {
if (number >= 10000000) {
return (number / 1000000).toFixed(0) + 'M'
}
if (number >= 1000000) {
return (number / 1000000).toFixed(1) + 'M'
}
if (number >= 10000) {
return (number / 1000).toFixed(0) + 'K'
}
if (number >= 1000) {
return (number / 1000).toFixed(1) + 'K'
}
return number
}
});