ruby codeclimate fixes
This commit is contained in:
parent
d51a22c5a9
commit
f9c139c19e
2 changed files with 30 additions and 29 deletions
|
@ -13,7 +13,7 @@ class NotificationsController < ApplicationController
|
||||||
receipt = @receipts.find_by(notification_id: notification.id)
|
receipt = @receipts.find_by(notification_id: notification.id)
|
||||||
NotificationDecorator.decorate(notification, receipt)
|
NotificationDecorator.decorate(notification, receipt)
|
||||||
end
|
end
|
||||||
if notifications.length > 0
|
if !notifications.empty?
|
||||||
render json: notifications
|
render json: notifications
|
||||||
else
|
else
|
||||||
render json: [].to_json
|
render json: [].to_json
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
class NotificationDecorator
|
class NotificationDecorator
|
||||||
class << self
|
class << self
|
||||||
def decorate(notification, receipt)
|
def decorate(notification, receipt)
|
||||||
|
@ -14,34 +15,34 @@ class NotificationDecorator
|
||||||
}
|
}
|
||||||
|
|
||||||
case notification.notification_code
|
case notification.notification_code
|
||||||
when MAP_ACCESS_APPROVED, MAP_ACCESS_REQUEST, MAP_INVITE_TO_EDIT
|
when MAP_ACCESS_APPROVED, MAP_ACCESS_REQUEST, MAP_INVITE_TO_EDIT
|
||||||
map = notification.notified_object&.map
|
map = notification.notified_object&.map
|
||||||
result[:data][:map] = {
|
result[:data][:map] = {
|
||||||
id: map&.id,
|
id: map&.id,
|
||||||
name: map&.name
|
name: map&.name
|
||||||
}
|
}
|
||||||
when TOPIC_ADDED_TO_MAP
|
when TOPIC_ADDED_TO_MAP
|
||||||
topic = notification.notified_object&.eventable
|
topic = notification.notified_object&.eventable
|
||||||
map = notification.notified_object&.map
|
map = notification.notified_object&.map
|
||||||
result[:data][:topic] = {
|
result[:data][:topic] = {
|
||||||
id: topic&.id,
|
id: topic&.id,
|
||||||
name: topic&.name
|
name: topic&.name
|
||||||
}
|
}
|
||||||
result[:data][:map] = {
|
result[:data][:map] = {
|
||||||
id: map&.id,
|
id: map&.id,
|
||||||
name: map&.name
|
name: map&.name
|
||||||
}
|
}
|
||||||
when TOPIC_CONNECTED_1, TOPIC_CONNECTED_2
|
when TOPIC_CONNECTED_1, TOPIC_CONNECTED_2
|
||||||
topic1 = notification.notified_object&.topic1
|
topic1 = notification.notified_object&.topic1
|
||||||
topic2 = notification.notified_object&.topic2
|
topic2 = notification.notified_object&.topic2
|
||||||
result[:data][:topic1] = {
|
result[:data][:topic1] = {
|
||||||
id: topic1&.id,
|
id: topic1&.id,
|
||||||
name: topic1&.name
|
name: topic1&.name
|
||||||
}
|
}
|
||||||
result[:data][:topic2] = {
|
result[:data][:topic2] = {
|
||||||
id: topic2&.id,
|
id: topic2&.id,
|
||||||
name: topic2&.name
|
name: topic2&.name
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
result
|
result
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue