mirror of
https://github.com/Homebrew/brew.git
synced 2025-07-14 16:09:03 +08:00
utils/analytics: improve accuracy of GitHub Packages download counts
`millions_match.captures.first` will typically be a decimal (since it's matched using `\d+\.\d+`), except we lose accuracy in the `#to_i` conversion. Before: ``` ❯ brew info --analytics --github-packages-downloads sqlite ==> Analytics ==> install (30 days) [snip] ==> GitHub Packages Downloads 1,009,898 (30 days) ``` After: ``` ❯ brew info --analytics --github-packages-downloads sqlite ==> Analytics ==> install (30 days) [snip] ==> GitHub Packages Downloads 1,199,898 (30 days) ``` In this case `1.19M` was being rounded down to `1M`.
This commit is contained in:
parent
822c84784c
commit
ab4f14b359
@ -307,7 +307,7 @@ module Utils
|
||||
|
||||
last_thirty_days_downloads = last_thirty_days_match.captures.first.tr(",", "")
|
||||
thirty_day_download_count += if (millions_match = last_thirty_days_downloads.match(/(\d+\.\d+)M/).presence)
|
||||
millions_match.captures.first.to_i * 1_000_000
|
||||
millions_match.captures.first.to_f * 1_000_000
|
||||
else
|
||||
last_thirty_days_downloads.to_i
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user