Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get rid of kind from the decision model #16024

Merged
merged 1 commit into from
Apr 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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 @@
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 @@

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 @@

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