aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobin H. Johnson <robbat2@gentoo.org>2008-06-06 03:08:36 +0000
committerRobin H. Johnson <robbat2@gentoo.org>2008-06-06 03:08:36 +0000
commit20bb0ec837354ef9fb48253910b9eb3cf65d240e (patch)
treec88666b57a9d79f7dd4a18a56e191e45dd7de19b
parentFix whitespace. (diff)
downloadrbot-bugzilla-20bb0ec837354ef9fb48253910b9eb3cf65d240e.tar.gz
rbot-bugzilla-20bb0ec837354ef9fb48253910b9eb3cf65d240e.tar.bz2
rbot-bugzilla-20bb0ec837354ef9fb48253910b9eb3cf65d240e.zip
Massive fixup of archstats to work in almost all input cases by being smarter than rbot.
-rw-r--r--bugzilla.rb80
1 files 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