Finished new report generation
This commit is contained in:
@@ -27,23 +27,30 @@ class ExceptionhandlerController < ApplicationController
|
|||||||
helper :exceptionhandler
|
helper :exceptionhandler
|
||||||
include ExceptionhandlerHelper
|
include ExceptionhandlerHelper
|
||||||
|
|
||||||
|
require 'logger'
|
||||||
|
|
||||||
def index
|
def index
|
||||||
# @bug_id = Tracker.find_by_name("Bug").id
|
log = Logger.new('redmine-exceptionhandler-plugin.txt')
|
||||||
# @issues = Project.find_by_name(params[:app]).issues
|
log.level = Logger::DEBUG
|
||||||
# @custom_fields = CustomField
|
log.debug "Loading Index"
|
||||||
|
|
||||||
if params.size < 8
|
if params.size < 8
|
||||||
@output = "<strong> not enough args </strong>"
|
@output = "<strong> not enough args </strong>"
|
||||||
|
elsif Project.find_by_name(params[:app]) == nil
|
||||||
|
@output = "No Project Found"
|
||||||
else
|
else
|
||||||
issue_id = check_for_existing_report
|
issue_id = check_for_existing_report
|
||||||
if issue_id > 0
|
if issue_id > 0
|
||||||
# TODO update report
|
# TODO update report
|
||||||
@output = issue_id
|
@output = issue_id
|
||||||
else
|
else
|
||||||
if file_new_report
|
#TODO create new report and save
|
||||||
@output = "new report filed"
|
issue = create_new_report
|
||||||
|
if issue.valid?
|
||||||
|
issue.save
|
||||||
|
@output = "Report filed, Thank You."
|
||||||
else
|
else
|
||||||
@output = "Failed to file report"
|
@output = issue.errors.full_messages
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -39,13 +39,11 @@ module ExceptionhandlerHelper
|
|||||||
# @return id of report if matching, else 0
|
# @return id of report if matching, else 0
|
||||||
def check_issue(issue)
|
def check_issue(issue)
|
||||||
if issue.subject == params[:msg]
|
if issue.subject == params[:msg]
|
||||||
# if issue.description == params[:description]
|
if check_issue_custom_values(issue)
|
||||||
if check_issue_custom_values(issue)
|
return issue.id
|
||||||
return issue.id
|
else
|
||||||
end
|
return 0
|
||||||
# else
|
end
|
||||||
# return 0
|
|
||||||
# end
|
|
||||||
else
|
else
|
||||||
return 0
|
return 0
|
||||||
end
|
end
|
||||||
@@ -81,18 +79,35 @@ module ExceptionhandlerHelper
|
|||||||
|
|
||||||
# files a new exception report in redmine
|
# files a new exception report in redmine
|
||||||
# @return true if new report was filed
|
# @return true if new report was filed
|
||||||
def file_new_report
|
def create_new_report
|
||||||
issue = Issue.new
|
issue = Issue.new
|
||||||
issue.tracker = Tracker.find_by_name("Bug")
|
issue.tracker = Tracker.find_by_name("Bug")
|
||||||
issue.subject = params[:msg]
|
issue.subject = params[:msg]
|
||||||
issue.description = params[:description]
|
issue.description = params[:description]
|
||||||
issue.project = Project.find_by_name(params[:app])
|
issue.project = Project.find_by_name(params[:app])
|
||||||
issue.start_date = Time.now.localtime.strftime("%Y-%m-%d")
|
issue.start_date = Time.now.localtime.strftime("%Y-%m-%d %T")
|
||||||
issue.priority = IssuePriority.find_by_name("Normal")
|
issue.priority = IssuePriority.find_by_name("Normal")
|
||||||
issue.author = User.find_by_mail("rickbarrette@gmail.com")
|
issue.author = User.find_by_mail("rickbarrette@gmail.com")
|
||||||
issue.status = IssueStatus.find_by_name("New")
|
issue.status = IssueStatus.find_by_name("New")
|
||||||
|
|
||||||
issue.save
|
issue.custom_values = [
|
||||||
|
create_custom_value(CustomField.find_by_name("StackTrace").id, params[:stackTrace]),
|
||||||
|
create_custom_value(CustomField.find_by_name("Cause").id, params[:cause]),
|
||||||
|
create_custom_value(CustomField.find_by_name("Count").id, "1"),
|
||||||
|
create_custom_value(CustomField.find_by_name("Device").id, params[:device]),
|
||||||
|
create_custom_value(CustomField.find_by_name("Version").id, value = params[:version]),
|
||||||
|
create_custom_value(CustomField.find_by_name("Date").id, value = params[:date])
|
||||||
|
]
|
||||||
|
return issue
|
||||||
end
|
end
|
||||||
|
|
||||||
end #EOF
|
# returns a new custom value
|
||||||
|
def create_custom_value(field_id, value)
|
||||||
|
custom_value = CustomValue.new
|
||||||
|
custom_value.custom_field_id = field_id
|
||||||
|
custom_value.value = value
|
||||||
|
custom_value.customized_type = "Issue"
|
||||||
|
return custom_value
|
||||||
|
end
|
||||||
|
|
||||||
|
end #EOF
|
||||||
|
|||||||
@@ -1,2 +1,3 @@
|
|||||||
<h1>Exception Handler</h1>
|
<h1>Exception Handler</h1>
|
||||||
<%= @output %>
|
<%= @output %>
|
||||||
|
<%= Rails.logger.info %>
|
||||||
|
|||||||
Reference in New Issue
Block a user