Skip to content

Commit

Permalink
Get rid of kind from the decision model
Browse files Browse the repository at this point in the history
  • Loading branch information
hellcp-work committed Apr 22, 2024
1 parent 6731487 commit fd3861f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 19 deletions.
4 changes: 1 addition & 3 deletions src/api/app/controllers/webui/decisions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ def create
private

def decision_params
# TODO: remove merge and replace decision_kind with decision_type
kind = params[:decision][:type] == 'DecisionFavored' ? 'favor' : 'cleared'
params.require(:decision).permit(:reason, :type, report_ids: []).merge(kind: kind)
params.require(:decision).permit(:reason, :type, report_ids: [])

Check warning on line 22 in src/api/app/controllers/webui/decisions_controller.rb

View check run for this annotation

Codecov / codecov/patch

src/api/app/controllers/webui/decisions_controller.rb#L22

Added line #L22 was not covered by tests
end
end
18 changes: 2 additions & 16 deletions src/api/app/models/decision.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,6 @@ class Decision < ApplicationRecord

has_many :reports, dependent: :nullify

# TODO: Remove this after type is deployed
enum kind: {
cleared: 0,
favor: 1
}

after_create :create_event
after_create :track_decision

def description
Expand All @@ -41,23 +34,16 @@ def self.display_name

private

# TODO: Replace this with `AbstractMethodCalled` after type is deployed
def create_event
case kind
when 'cleared'
Event::ClearedDecision.create(event_parameters)
else
Event::FavoredDecision.create(event_parameters)
end
raise AbstractMethodCalled

Check warning on line 38 in src/api/app/models/decision.rb

View check run for this annotation

Codecov / codecov/patch

src/api/app/models/decision.rb#L38

Added line #L38 was not covered by tests
end

def event_parameters
{ id: id, moderator_id: moderator.id, reason: reason, report_last_id: reports.last.id, reportable_type: reports.first.reportable.class.name }
end

# TODO: Remove kind after type is deployed
def track_decision
RabbitmqBus.send_to_bus('metrics', "decision,kind=#{kind},type=#{type} hours_before_decision=#{hours_before_decision},count=1")
RabbitmqBus.send_to_bus('metrics', "decision,type=#{type} hours_before_decision=#{hours_before_decision},count=1")
end

def hours_before_decision
Expand Down

0 comments on commit fd3861f

Please sign in to comment.