From 20bb0ec837354ef9fb48253910b9eb3cf65d240e Mon Sep 17 00:00:00 2001 From: "Robin H. Johnson" Date: Fri, 6 Jun 2008 03:08:36 +0000 Subject: Massive fixup of archstats to work in almost all input cases by being smarter than rbot. --- bugzilla.rb | 80 ++++++++++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 61 insertions(+), 19 deletions(-) diff --git a/bugzilla.rb b/bugzilla.rb index f867401..ad14f3d 100644 --- a/bugzilla.rb +++ b/bugzilla.rb @@ -486,13 +486,62 @@ class BugzillaPlugin < Plugin # x_axis_field=rep_platform&resolution=FIXED&resolution=INVALID&resolution=WONTFIX def archstats(m, params) begin - status = params[:status] - reso = params[:reso] + # First of all, we need to fix up the input + # as rbot gets it confused sometimes + # First we take them in the original order + begin + newparams = [] + newparams << params[:zilla] if params[:zilla] + newparams << params[:status] if params[:status] + newparams << params[:reso] if params[:reso] + params = newparams + end + + zilla = nil + status = nil + reso = nil - # rbot gets the assignment order wrong sometimes - if reso and status.nil? - status = reso - reso = nil + #m.reply "p:#{params.inspect} s=#{status} r=#{reso} z=#{zilla}" + + params.each_index do |i| + v = params[i] + next if v.nil? + if v =~ STATUS_INPUT_N + status = v + params.delete_at(i) + break + end + end + #m.reply "p:#{params.inspect} s=#{status} r=#{reso} z=#{zilla}" + + params.each_index do |i| + v = params[i] + next if v.nil? + if v =~ RESO_INPUT_N + reso = v + params.delete_at(i) + break + end + end + #m.reply "p:#{params.inspect} s=#{status} r=#{reso} z=#{zilla}" + + case params.length + when 1 + zilla = params[0] + check_zilla(zilla) + zilla = @zillas[zilla] + when 0 + zilla = get_zilla(m) + else + zilla = nil + m.reply "Wrong parameters, see 'help archstats' for help." + return + end + #m.reply "p:#{params.inspect} s=#{status} r=#{reso} z=#{zilla.to_s}" + + if zilla.nil? + m.reply "Wrong parameters (no bugzilla provided), see 'help archstats' for help." + return end # Now the real defaults @@ -501,17 +550,19 @@ class BugzillaPlugin < Plugin # Validate all input status = status.split(/,/) + exclude_reso = true status.each do |s| - reso = [] unless DONE_STATUS.include?(s) - raise ENotFound.new("Invalid status (#{s}), see 'help archstats' for help.") if not DONE_STATUS.include?(s) and not OPEN_STATUS.include?(s) and s != 'ALL' + exclude_reso = false if DONE_STATUS.include?(s) or s == 'ALL' + raise ArgumentError.new("Invalid status (#{s}), see 'help archstats' for help.") if not DONE_STATUS.include?(s) and not OPEN_STATUS.include?(s) and s != 'ALL' end + reso = [] if exclude_reso reso = reso.split(/,/) if reso and reso.is_a?(String) reso.each do |r| - raise ENotFound.new("Invalid resolution (#{r}), see 'help archstats' for help.") if not VALID_RESO.include?(r) + raise ArgumentError.new("Invalid resolution (#{r}), see 'help archstats' for help.") if not VALID_RESO.include?(r) end # Nice header - title = "Platform bug totals" + title = "#{zilla.name.capitalize} platform bug totals" if status.length > 0 or reso.length > 0 title += " (#{status.join(',')}" title += "/#{reso.join(',')}" if reso.length > 0 @@ -543,15 +594,6 @@ class BugzillaPlugin < Plugin reso.each { |r| query += "&resolution=#{r}" } # Get the data - if params[:zilla] - check_zilla(params[:zilla]) - zilla = @zillas[params[:zilla]] - elsif get_zilla(m) - zilla = get_zilla(m) - else - m.reply "Wrong parameters, see 'help archstats' for help." - return - end results = zilla.report(query) # Remove the CSV header -- cgit v1.2.3-65-gdbad