Skip to content

Commit

Permalink
saves one update in case of new issues
Browse files Browse the repository at this point in the history
- and possibly fixes the 2 occurrences on newly created issues
  • Loading branch information
jkraemer committed Jun 20, 2016
1 parent 6daeed5 commit a834468
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions app/controllers/notices_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -86,22 +86,23 @@ def create_or_update_issue(redmine_params, notice)

# set custom field error class
cf_values = { @error_class_field.id => error_class,
@occurences_field.id => 0 }
@occurences_field.id => 1 }
unless redmine_params["environment"].blank?
cf_values[@environment_field.id] = redmine_params["environment"]
end
issue.custom_field_values = cf_values
issue.skip_notification = true
issue.save!
end

# increment occurences custom field
if value = issue.custom_value_for(@occurences_field)
value.update_attribute :value, (value.value.to_i + 1).to_s
else
issue.custom_values.create!(:value => 1, :custom_field => @occurences_field)
# increment occurences custom field
if value = issue.custom_value_for(@occurences_field)
value.update_attribute :value, (value.value.to_i + 1).to_s
else
issue.custom_values.create!(:value => 1, :custom_field => @occurences_field)
end
end


# create the journal entry, update issue attributes
retried_once = false # we retry once in case of a StaleObjectError
begin
Expand Down

0 comments on commit a834468

Please sign in to comment.