From 28df07fc7df8457a92ce131eefd3ac93f734e3dc Mon Sep 17 00:00:00 2001 From: "Robin H. Johnson" Date: Fri, 6 Jun 2008 04:47:55 +0000 Subject: Include ability to do totals in the reports. --- bugzilla.rb | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/bugzilla.rb b/bugzilla.rb index fe8a2b5..7987b82 100644 --- a/bugzilla.rb +++ b/bugzilla.rb @@ -352,9 +352,19 @@ class BugzillaPlugin < Plugin self.lastseenid = buglist[-1][0].to_i if buglist.size > 0 end - def report(params) - url = "#{reporturl}&#{params}" + def report(urlparams, params = nil) + url = "#{reporturl}&#{urlparams}" reportdata = CSV::Reader.create(@bot.httputil.get(url)).to_a + if params and params[:total] + sum = 0 + column = params[:total] + reportdata.each do |row| + if row[column] =~ /^[0-9]+$/ + sum += row[column].to_i + end + end + reportdata << ["Total", sum] + end return reportdata end @@ -497,7 +507,7 @@ class BugzillaPlugin < Plugin #reso.each { |r| query += "&resolution=#{r}" } # Get the data - results = zilla.report(query) + results = zilla.report(query, {:total => 1}) # Remove the CSV header results.shift @@ -628,7 +638,7 @@ class BugzillaPlugin < Plugin reso.each { |r| query += "&resolution=#{r}" } # Get the data - results = zilla.report(query) + results = zilla.report(query, {:total => 1}) # Remove the CSV header results.shift -- cgit v1.2.3-65-gdbad