summaryrefslogtreecommitdiffstats
path: root/modules/base
diff options
context:
space:
mode:
authorGusted <williamzijl7@hotmail.com>2022-06-12 14:08:23 +0200
committerGitHub <noreply@github.com>2022-06-12 20:08:23 +0800
commit796c4eca0bacf67c186768de66fcfee21867045f (patch)
tree3fc7947372c955953c0c6d443b05d3585a6ce300 /modules/base
parent0097fbc2ac153a686b68af43e791704e9b5cf74b (diff)
downloadgitea-796c4eca0bacf67c186768de66fcfee21867045f.tar.gz
gitea-796c4eca0bacf67c186768de66fcfee21867045f.zip
Prettify number of issues (#17760)
* Prettify number of issues - Use the PrettyNumber function to add commas in large amount of issues. * Use client-side formatting * prettify on both server and client * remove unused i18n entries * handle more cases, support other int types in PrettyNumber * specify locale to avoid issues with node default locale * remove superfluos argument * introduce template helper, octicon tweaks, js refactor * Update modules/templates/helper.go * Apply some suggestions. * Add comment * Update templates/user/dashboard/issues.tmpl Co-authored-by: silverwind <me@silverwind.io> Co-authored-by: silverwind <me@silverwind.io> Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Diffstat (limited to 'modules/base')
-rw-r--r--modules/base/tool.go7
-rw-r--r--modules/base/tool_test.go1
2 files changed, 5 insertions, 3 deletions
diff --git a/modules/base/tool.go b/modules/base/tool.go
index 47ce125853..a981fd6c57 100644
--- a/modules/base/tool.go
+++ b/modules/base/tool.go
@@ -24,6 +24,7 @@ import (
"code.gitea.io/gitea/modules/git"
"code.gitea.io/gitea/modules/log"
"code.gitea.io/gitea/modules/setting"
+ "code.gitea.io/gitea/modules/util"
"github.com/dustin/go-humanize"
)
@@ -143,9 +144,9 @@ func FileSize(s int64) string {
}
// PrettyNumber produces a string form of the given number in base 10 with
-// commas after every three orders of magnitud
-func PrettyNumber(v int64) string {
- return humanize.Comma(v)
+// commas after every three orders of magnitude
+func PrettyNumber(i interface{}) string {
+ return humanize.Comma(util.NumberIntoInt64(i))
}
// Subtract deals with subtraction of all types of number.
diff --git a/modules/base/tool_test.go b/modules/base/tool_test.go
index 5280827e8a..6685168bac 100644
--- a/modules/base/tool_test.go
+++ b/modules/base/tool_test.go
@@ -117,6 +117,7 @@ func TestFileSize(t *testing.T) {
func TestPrettyNumber(t *testing.T) {
assert.Equal(t, "23,342,432", PrettyNumber(23342432))
+ assert.Equal(t, "23,342,432", PrettyNumber(int32(23342432)))
assert.Equal(t, "0", PrettyNumber(0))
assert.Equal(t, "-100,000", PrettyNumber(-100000))
}