Merge lp:~diegosarmentero/click-update-manager/bytes-to-size into lp:click-update-manager
Status: | Merged |
---|---|
Approved by: | Diego Sarmentero on 2013-10-16 |
Approved revision: | 44 |
Merged at revision: | 36 |
Proposed branch: | lp:~diegosarmentero/click-update-manager/bytes-to-size |
Merge into: | lp:click-update-manager |
Diff against target: |
105 lines (+47/-2) 5 files modified
CMakeLists.txt (+1/-0) Components/PageUpdate.qml (+2/-1) js/utils.js (+39/-0) tests/unit/tst_pageupdate.qml (+1/-1) updatemanager.qmlproject (+4/-0) |
To merge this branch: | bzr merge lp:~diegosarmentero/click-update-manager/bytes-to-size |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
PS Jenkins bot (community) | continuous-integration | Approve on 2013-10-16 | |
Mike McCracken (community) | 2013-10-09 | Approve on 2013-10-16 | |
dobey (community) | Approve on 2013-10-16 | ||
Roberto Alsina (community) | Approve on 2013-10-16 | ||
Review via email:
|
Commit message
- Show app size in the proper way (BUG: #1232256).
- 37. By Diego Sarmentero on 2013-10-09
-
fix if comparison
Mike McCracken (mikemc) wrote : | # |
In utils.js, the calculation "parseFloat(bytes / 1024).toFixed(2)" is strange.
per IRC, bytes will be an int, so we're dividing two ints then apparently implicitly converting them to strings before passing them to parseFloat(), which generates a float.
If you just remove "parseFloat" and divide by a float, it works the same but makes more sense to me.
like this:
var size = (bytes / 1024.0).toFixed(2);
Mike McCracken (mikemc) wrote : | # |
http://
- 38. By Diego Sarmentero on 2013-10-11
-
removing parseFloat
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:38
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
- 39. By Diego Sarmentero on 2013-10-14
-
update cmake
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:39
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
- 40. By Diego Sarmentero on 2013-10-15
-
revert desktop file name
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:40
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
- 41. By Diego Sarmentero on 2013-10-16
-
adding desktop file
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:41
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
- 42. By Diego Sarmentero on 2013-10-16
-
adding GiB to convert function
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:42
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
dobey (dobey) wrote : | # |
> === added file 'click-
> === removed file 'click-
Huh? How can it be both added and removed in the same diff? And which one is correct?
82 +function convert_
83 + var result = "";
84 + var size = (bytes / 1024.0).toFixed(2);
85 + if(size < 1024) {
86 + result = size + " KiB";
87 + } else if(size < 1048576) {
88 + size = (size / 1024.0).toFixed(2);
89 + result = size + " MiB";
90 + } else {
91 + size = (size / 1048576.
92 + result = size + " GiB";
93 + }
94 +
95 + return result;
96 +}
This code is really hard to read, because the checks are inconsistent, and you're converting bytes to KiB from the start, but use "size" as a variable name. Why not just use the input "bytes" variable across the board for checking, and only place the reduced size in the result string? Something like this perhaps:
var SIZE_IN_GIB = 1024.0 * 1024.0 * 1024.0;
var SIZE_IN_MIB = 1024.0 * 1024.0;
var SIZE_IN_KIB = 1024.0;
var result = "";
var size = 0;
if (bytes / SIZE_IN_KIB < SIZE_IN_KIB) {
size = bytes / SIZE_IN_KIB;
result = size + " KiB";
} else if (bytes / SIZE_IN_MIB < SIZE_IN_KIB) {
size = bytes / SIZE_IN_MIB;
result = size + " MiB";
} else if (bytes / SIZE_IN_GIB < SIZE_IN_KIB) {
size = bytes / SIZE_IN_GIB;
result = size + " GiB";
} else {
result = bytes + " bytes";
}
return result;
- 43. By Diego Sarmentero on 2013-10-16
-
improve convert function
Diego Sarmentero (diegosarmentero) wrote : | # |
> > === added file 'click-
> > === removed file 'click-
>
> Huh? How can it be both added and removed in the same diff? And which one is
> correct?
>
> 82 +function convert_
> 83 + var result = "";
> 84 + var size = (bytes / 1024.0).toFixed(2);
> 85 + if(size < 1024) {
> 86 + result = size + " KiB";
> 87 + } else if(size < 1048576) {
> 88 + size = (size / 1024.0).toFixed(2);
> 89 + result = size + " MiB";
> 90 + } else {
> 91 + size = (size / 1048576.
> 92 + result = size + " GiB";
> 93 + }
> 94 +
> 95 + return result;
> 96 +}
>
> This code is really hard to read, because the checks are inconsistent, and
> you're converting bytes to KiB from the start, but use "size" as a variable
> name. Why not just use the input "bytes" variable across the board for
> checking, and only place the reduced size in the result string? Something like
> this perhaps:
>
> var SIZE_IN_GIB = 1024.0 * 1024.0 * 1024.0;
> var SIZE_IN_MIB = 1024.0 * 1024.0;
> var SIZE_IN_KIB = 1024.0;
>
> var result = "";
> var size = 0;
> if (bytes / SIZE_IN_KIB < SIZE_IN_KIB) {
> size = bytes / SIZE_IN_KIB;
> result = size + " KiB";
> } else if (bytes / SIZE_IN_MIB < SIZE_IN_KIB) {
> size = bytes / SIZE_IN_MIB;
> result = size + " MiB";
> } else if (bytes / SIZE_IN_GIB < SIZE_IN_KIB) {
> size = bytes / SIZE_IN_GIB;
> result = size + " GiB";
> } else {
> result = bytes + " bytes";
> }
>
> return result;
Fixed
- 44. By Diego Sarmentero on 2013-10-16
-
revert renaming desktop file
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:43
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
FAILED: Continuous integration, rev:37 jenkins. qa.ubuntu. com/job/ click-update- manager- ci/35/ jenkins. qa.ubuntu. com/job/ click-update- manager- saucy-amd64- ci/35/console jenkins. qa.ubuntu. com/job/ click-update- manager- saucy-armhf- ci/35/console
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild: 10.97.0. 26:8080/ job/click- update- manager- ci/35/rebuild
http://