move methods to analytics_table function
This commit is contained in:
parent
af59951c0e
commit
1ab86acb0f
@ -231,6 +231,18 @@ module Homebrew
|
||||
end
|
||||
|
||||
def analytics_table(category, days, results, os_version: false, cask_install: false)
|
||||
valid_days = %w[30 90 365]
|
||||
if days.present?
|
||||
raise UsageError, "day must be one of #{valid_days.join(", ")}" unless valid_days.include?(days.to_s)
|
||||
end
|
||||
|
||||
valid_categories = %w[install install-on-request cask-install build-error os-version]
|
||||
if category.present?
|
||||
unless valid_categories.include?(category.tr("_", "-"))
|
||||
raise UsageError, "category must be one of #{valid_categories.join(", ")}"
|
||||
end
|
||||
end
|
||||
|
||||
oh1 "#{category} (#{days} days)"
|
||||
total_count = results.values.inject("+")
|
||||
formatted_total_count = format_count(total_count)
|
||||
@ -357,8 +369,6 @@ module Homebrew
|
||||
end
|
||||
|
||||
def output_formula_analytics(f)
|
||||
valid_days = %w[30 90 365]
|
||||
valid_categories = %w[install install-on-request build-error]
|
||||
json = formulae_api_json("formula/#{f}.json")
|
||||
return if json.blank? || json["analytics"].blank?
|
||||
|
||||
@ -372,14 +382,10 @@ module Homebrew
|
||||
days = days.to_i
|
||||
if full_analytics
|
||||
if args.days.present?
|
||||
raise UsageError, "day must be one of #{valid_days.join(", ")}" unless valid_days.include?(args.days)
|
||||
next if args.days&.to_i != days
|
||||
end
|
||||
|
||||
if args.category.present?
|
||||
unless valid_categories.include?(args.category)
|
||||
raise UsageError, "category must be one of #{valid_categories.join(", ")}"
|
||||
end
|
||||
next if args.category.tr("-", "_") != category
|
||||
end
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user