Merge pull request #5146 from MikeMcQuaid/tweak-analytics-results
info: tweak analytics behaviour.
This commit is contained in:
commit
7a4a5d809f
@ -14,7 +14,10 @@
|
|||||||
#: Display information about <formula> and analytics data (provided neither
|
#: Display information about <formula> and analytics data (provided neither
|
||||||
#: `HOMEBREW_NO_ANALYTICS` or `HOMEBREW_NO_GITHUB_API` are set)
|
#: `HOMEBREW_NO_ANALYTICS` or `HOMEBREW_NO_GITHUB_API` are set)
|
||||||
#:
|
#:
|
||||||
#: Pass `--analytics` to see more detailed analytics data.
|
#: Pass `--verbose` to see more verbose analytics data.
|
||||||
|
#:
|
||||||
|
#: Pass `--analytics` to see only more verbose analytics data instead of
|
||||||
|
#: formula information.
|
||||||
#:
|
#:
|
||||||
#: * `info` `--github` <formula>:
|
#: * `info` `--github` <formula>:
|
||||||
#: Open a browser to the GitHub History page for <formula>.
|
#: Open a browser to the GitHub History page for <formula>.
|
||||||
@ -66,12 +69,21 @@ module Homebrew
|
|||||||
ARGV.named.each_with_index do |f, i|
|
ARGV.named.each_with_index do |f, i|
|
||||||
puts unless i.zero?
|
puts unless i.zero?
|
||||||
begin
|
begin
|
||||||
if f.include?("/") || File.exist?(f)
|
formula = if f.include?("/") || File.exist?(f)
|
||||||
info_formula Formulary.factory(f)
|
Formulary.factory(f)
|
||||||
else
|
else
|
||||||
info_formula Formulary.find_with_priority(f)
|
Formulary.find_with_priority(f)
|
||||||
|
end
|
||||||
|
if ARGV.include?("--analytics")
|
||||||
|
output_formula_analytics(formula)
|
||||||
|
else
|
||||||
|
info_formula(formula)
|
||||||
end
|
end
|
||||||
rescue FormulaUnavailableError => e
|
rescue FormulaUnavailableError => e
|
||||||
|
if ARGV.include?("--analytics")
|
||||||
|
output_analytics(filter: f)
|
||||||
|
next
|
||||||
|
end
|
||||||
ofail e.message
|
ofail e.message
|
||||||
# No formula with this name, try a missing formula lookup
|
# No formula with this name, try a missing formula lookup
|
||||||
if (reason = MissingFormula.reason(f))
|
if (reason = MissingFormula.reason(f))
|
||||||
@ -295,7 +307,7 @@ module Homebrew
|
|||||||
"#{formatted_total_count_footer} | #{formatted_total_percent_footer}%"
|
"#{formatted_total_count_footer} | #{formatted_total_percent_footer}%"
|
||||||
end
|
end
|
||||||
|
|
||||||
def output_analytics
|
def output_analytics(filter: nil)
|
||||||
days = ARGV.value("days") || "30"
|
days = ARGV.value("days") || "30"
|
||||||
valid_days = %w[30 90 365]
|
valid_days = %w[30 90 365]
|
||||||
unless valid_days.include?(days)
|
unless valid_days.include?(days)
|
||||||
@ -319,8 +331,17 @@ module Homebrew
|
|||||||
else
|
else
|
||||||
item["formula"]
|
item["formula"]
|
||||||
end
|
end
|
||||||
|
if filter.present?
|
||||||
|
next if key != filter && !key.start_with?("#{filter} ")
|
||||||
|
end
|
||||||
results[key] = item["count"].tr(",", "").to_i
|
results[key] = item["count"].tr(",", "").to_i
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if filter.present? && results.blank?
|
||||||
|
onoe "No results matching `#{filter}` found!"
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
analytics_table(category, days, results, os_version: os_version)
|
analytics_table(category, days, results, os_version: os_version)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@ -212,7 +212,10 @@ With `--verbose` or `-v`, many commands print extra debugging information. Note
|
|||||||
Display information about *`formula`* and analytics data (provided neither
|
Display information about *`formula`* and analytics data (provided neither
|
||||||
`HOMEBREW_NO_ANALYTICS` or `HOMEBREW_NO_GITHUB_API` are set)
|
`HOMEBREW_NO_ANALYTICS` or `HOMEBREW_NO_GITHUB_API` are set)
|
||||||
|
|
||||||
Pass `--analytics` to see more detailed analytics data.
|
Pass `--verbose` to see more verbose analytics data.
|
||||||
|
|
||||||
|
Pass `--analytics` to see only more verbose analytics data instead of
|
||||||
|
formula information.
|
||||||
|
|
||||||
* `info` `--github` *`formula`*:
|
* `info` `--github` *`formula`*:
|
||||||
Open a browser to the GitHub History page for *`formula`*.
|
Open a browser to the GitHub History page for *`formula`*.
|
||||||
|
|||||||
@ -222,7 +222,10 @@ The value for \fBcategory\fR must be \fBinstall\fR, \fBinstall\-on\-request\fR,
|
|||||||
Display information about \fIformula\fR and analytics data (provided neither \fBHOMEBREW_NO_ANALYTICS\fR or \fBHOMEBREW_NO_GITHUB_API\fR are set)
|
Display information about \fIformula\fR and analytics data (provided neither \fBHOMEBREW_NO_ANALYTICS\fR or \fBHOMEBREW_NO_GITHUB_API\fR are set)
|
||||||
.
|
.
|
||||||
.IP
|
.IP
|
||||||
Pass \fB\-\-analytics\fR to see more detailed analytics data\.
|
Pass \fB\-\-verbose\fR to see more verbose analytics data\.
|
||||||
|
.
|
||||||
|
.IP
|
||||||
|
Pass \fB\-\-analytics\fR to see only more verbose analytics data instead of formula information\.
|
||||||
.
|
.
|
||||||
.TP
|
.TP
|
||||||
\fBinfo\fR \fB\-\-github\fR \fIformula\fR
|
\fBinfo\fR \fB\-\-github\fR \fIformula\fR
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user