Skip to content

Commit 1e11bdc

Browse files
committed
chore: rubocop linter fix
1 parent 15e9f17 commit 1e11bdc

File tree

6 files changed

+21
-17
lines changed

6 files changed

+21
-17
lines changed

app/controllers/api/v1/feedbacks_controller.rb

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ def index
1616

1717
feedbacks = Feedback.recent.includes(:feedback_votes)
1818
feedbacks = feedbacks.by_category(params[:category]) if params[:category].present?
19-
feedbacks = feedbacks.where(status: params[:status]) if params[:status].present?
19+
feedbacks = feedbacks.where(status: params[:status]) if params[:status].present?
2020

2121
result = paginate(feedbacks)
2222
items = result[:data].map { |f| feedback_data(f, user: current_user) }
@@ -31,9 +31,11 @@ def create
3131
feedback.organization = current_organization
3232

3333
if feedback.save
34-
render_created({ feedback: feedback_data(feedback, user: current_user) }, message: 'Feedback submitted successfully')
34+
render_created({ feedback: feedback_data(feedback, user: current_user) },
35+
message: 'Feedback submitted successfully')
3536
else
36-
render_error(message: 'Invalid feedback', code: 'VALIDATION_ERROR', status: :unprocessable_entity, details: feedback.errors.as_json)
37+
render_error(message: 'Invalid feedback', code: 'VALIDATION_ERROR', status: :unprocessable_entity,
38+
details: feedback.errors.as_json)
3739
end
3840
end
3941

@@ -65,15 +67,15 @@ def feedback_params
6567
def feedback_data(feedback, user: nil)
6668
voted = user ? feedback.feedback_votes.any? { |v| v.user_id == user.id } : false
6769
{
68-
id: feedback.id,
69-
category: feedback.category,
70-
title: feedback.title,
70+
id: feedback.id,
71+
category: feedback.category,
72+
title: feedback.title,
7173
description: feedback.description,
72-
rating: feedback.rating,
73-
status: feedback.status,
74+
rating: feedback.rating,
75+
status: feedback.status,
7476
votes_count: feedback.votes_count,
75-
user_voted: voted,
76-
created_at: feedback.created_at
77+
user_voted: voted,
78+
created_at: feedback.created_at
7779
}
7880
end
7981
end

app/models/feedback.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,5 @@ class Feedback < ApplicationRecord
2323

2424
scope :open, -> { where(status: 'open') }
2525
scope :recent, -> { order(created_at: :desc) }
26-
scope :by_category, lambda { |cat| where(category: cat) }
26+
scope :by_category, ->(cat) { where(category: cat) }
2727
end

config/routes.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,9 @@
6767

6868
# Feedback
6969
resources :feedbacks, only: %i[index create] do
70-
member { post :vote }
70+
member do
71+
post :vote
72+
end
7173
end
7274

7375
# Notifications

db/migrate/20260322120000_restore_messages_recipient_id.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ def up
3030
end
3131

3232
# Add recipient_id index for FK lookups
33-
unless index_exists?(:messages, :recipient_id)
34-
add_index :messages, :recipient_id
35-
end
33+
return if index_exists?(:messages, :recipient_id)
34+
35+
add_index :messages, :recipient_id
3636
end
3737

3838
def down

db/migrate/20260323120000_create_feedbacks.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ def change
99
t.string :title, null: false
1010
t.text :description, null: false
1111
t.integer :rating
12-
t.string :status, null: false, default: 'open'
12+
t.string :status, null: false, default: 'open'
1313

1414
t.timestamps
1515
end

db/migrate/20260323130000_create_feedback_votes.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ def change
99
t.timestamps
1010
end
1111

12-
add_index :feedback_votes, [:feedback_id, :user_id], unique: true
12+
add_index :feedback_votes, %i[feedback_id user_id], unique: true
1313

1414
add_column :feedbacks, :votes_count, :integer, null: false, default: 0
1515
end

0 commit comments

Comments
 (0)