Display popularity with less decimal points

Message ID 20191027010955.101640-1-lfleischer@archlinux.org
State New
Headers show
Series
  • Display popularity with less decimal points
Related show

Commit Message

Lukas Fleischer Oct. 27, 2019, 1:09 a.m. UTC
Limit the display to two decimal points for packages with a popularity
of at least 0.2.

Suggested-by: Allan McRae <allan@archlinux.org>
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
---
 web/template/pkg_details.php     | 2 +-
 web/template/pkgbase_details.php | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

Patch

diff --git a/web/template/pkg_details.php b/web/template/pkg_details.php
index 650c245..93b5f1e 100644
--- a/web/template/pkg_details.php
+++ b/web/template/pkg_details.php
@@ -259,7 +259,7 @@  endif;
 		</tr>
 		<tr>
 			<th><?= __('Popularity') . ': ' ?></th>
-			<td><?= number_format($popularity, 6) ?></td>
+			<td><?= number_format($popularity, $popularity >= .2 ? 2 : 6) ?></td>
 		</tr>
 		<tr>
 			<th><?= __('First Submitted') . ': ' ?></th>
diff --git a/web/template/pkgbase_details.php b/web/template/pkgbase_details.php
index 8a6e2b4..b2ce8cb 100644
--- a/web/template/pkgbase_details.php
+++ b/web/template/pkgbase_details.php
@@ -108,7 +108,7 @@  endif;
 		</tr>
 		<tr>
 			<th><?= __('Popularity') . ': ' ?></th>
-			<td><?= number_format($popularity, 6) ?></td>
+			<td><?= number_format($popularity, $popularity >= .2 ? 2 : 6) ?></td>
 		</tr>
 		<tr>
 			<th><?= __('First Submitted') . ': ' ?></th>