Fixes: https://pagure.io/koji/issue/2943
It is not quite universal and not addressing the issue I've mentioned (still have access to exact value).
1) Extend the function for more relevant units (if value < 10^3 return value, elif value < 10^6 .. kb, < 10^9 MB, else GB) 2) Add option natural=True -> In such case, conversion will be done, otherwise original behaviour (just add commas) is used 3) Where it is used in web ui, display natural=True by default and for mouseover (e.g. via title depending on underlying tag) display it with natural=False.
natural=True
title
I think this method should be renamed, rather than adding a new kwarg
rebased onto b42555f2d6e466c44ce44f053f9258f14bd34a2b
rebased onto f91c11ea89157b33a14b9d194f75fab36f080d4a
@tkopecek @ktdreyer fixed. Now we have two methods (formatThousands and formatNatural). Default for webUI is formatNatural, added hover text on size, which shows formatThousands size. This function is used not only for rpminfo page, but also for fileinfo, imageinfo and archiveinfo.
This works great in my testing.
:thumbsup:
By the way, here's how I tested this with the fakeweb utility in the tree.
fakeweb
devtools/fakeweb.conf
[web] SiteName = koji KojiHubURL = https://koji.fedoraproject.org/kojihub KojiFilesURL = https://kojipkgs.fedoraproject.org/ Secret = toomanysecrets PythonDebug = on LogLevel = DEBUG # prevent web code from tweaking the path LibPath = /nosuchpath
Run ./devtools/fakeweb
./devtools/fakeweb
Open http://localhost:8000/rpminfo?rpmID=28392141 in the browser
WIthout this change, the web UI shows "Size 6,276,266". WIth this change, it shows "Size 5.99 MB"
Metadata Update from @tkopecek: - Pull-request tagged with: testing-ready
rebased onto af20dc9243ffbc13759a91fcd8925dd162e1321e
rebased onto b44d77a7c6da241a357b13498a4a12d6b38e590e
Metadata Update from @jobrauer: - Pull-request tagged with: testing-done
Commit f2f4a3dc fixes this pull-request
Pull-Request has been merged by tkopecek
Fixes: https://pagure.io/koji/issue/2943