aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobin H. Johnson <robbat2@gentoo.org>2008-06-04 09:34:17 +0000
committerRobin H. Johnson <robbat2@gentoo.org>2008-06-04 09:34:17 +0000
commit70187ae864877d39b1dd1e4110e5a5312dd21a26 (patch)
tree990b89b6562ae920e928d0e17c18de7361908ca2
parentArchstats is nearly perfect. Needs a little more work on the params. (diff)
downloadrbot-bugzilla-70187ae864877d39b1dd1e4110e5a5312dd21a26.tar.gz
rbot-bugzilla-70187ae864877d39b1dd1e4110e5a5312dd21a26.tar.bz2
rbot-bugzilla-70187ae864877d39b1dd1e4110e5a5312dd21a26.zip
Clean up params.
-rw-r--r--bugzilla.rb45
1 files changed, 32 insertions, 13 deletions
diff --git a/bugzilla.rb b/bugzilla.rb
index 7e86c85..a13637b 100644
--- a/bugzilla.rb
+++ b/bugzilla.rb
@@ -466,10 +466,18 @@ class BugzillaPlugin < Plugin
begin
status = params[:status]
reso = params[:reso]
-
- status = ['ALL'] unless status
- reso = [] unless reso
+
+ # rbot gets the assignment order wrong sometimes
+ if reso and status.nil?
+ status = reso
+ reso = nil
+ end
+
+ # Now the real defaults
+ status = 'ALL' unless status
+ reso = '' unless reso
+ # Validate all input
status = status.split(/,/)
status.each do |s|
reso = [] unless DONE_STATUS.include?(s)
@@ -479,14 +487,21 @@ class BugzillaPlugin < Plugin
reso.each do |r|
raise ENotFound.new("Invalid resolution (#{r}), see 'help archstats' for help.") if not VALID_RESO.include?(r)
end
+
+ # Nice header
title = "Platform bug totals"
if status.length > 0 or reso.length > 0
title += " (#{status.join(',')}"
- title += "/#{reso.join(',')} " if reso.length > 0
+ title += "/#{reso.join(',')}" if reso.length > 0
title += ")"
end
- status.delete('ALL')
+ # Special cases
+ if status.include?('ALL')
+ status << 'OPEN'
+ status << 'DONE'
+ status.delete('ALL')
+ end
if status.include?('OPEN')
status += OPEN_STATUS
@@ -495,15 +510,17 @@ class BugzillaPlugin < Plugin
end
if status.include?('DONE')
- status += DONE_STATUS
+ status += DONE_STATUS
status.uniq!
status.delete('DONE')
end
-
+
+ # Build our URL
query = 'x_axis_field=rep_platform'
status.each { |s| query += "&bug_status=#{s}" }
reso.each { |r| query += "&resolution=#{r}" }
+ # Get the data
if params[:zilla]
check_zilla(params[:zilla])
results = @zillas[params[:zilla]].report(query)
@@ -513,10 +530,12 @@ class BugzillaPlugin < Plugin
m.reply "Wrong parameters, see 'help archstats' for help."
return
end
-
+
+ # Remove the CSV header
results.shift
- msg = results.map { |b| "#{b[0]}(#{b[1]})" }.join(' ')
- m.reply "#{title} #{msg}"
+
+ # Display output
+ m.reply title+" "+(results.map { |b| "#{b[0]}(#{b[1]})" }.join(' '))
rescue ::Exception => e
m.reply e.message
@@ -618,7 +637,7 @@ class BugzillaPlugin < Plugin
else
_channel_defaults_reload_set(chanrexp, defaults)
end
- end
+ end
rescue ::Exception => e
if m
m.reply e.message
@@ -800,8 +819,8 @@ plugin.map 'archstats :zilla :status :reso',
:zilla => /^[^ ]+$/
},
:defaults => {
- :status => 'ALL',
- :resolution => '',
+ :status => nil,
+ :resolution => nil,
},
:auth_path => 'view'