Skip to content

Commit

Permalink
Cleanup - review comment.
Browse files Browse the repository at this point in the history
  • Loading branch information
svogt0511 committed Dec 11, 2023
1 parent 1ddec2e commit 87cb73b
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions app/serializers/activity_serializer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class ActivitySerializer
:version

attribute :changes do |object, params|
# Object is of different class if it comes from /activities/:uid
if object.is_a? Activity
changes = object.audited_changes
action = object.action
Expand All @@ -22,16 +23,15 @@ class ActivitySerializer
action = object._source.action
end

pub = changes.dig("publisher")
pub_obj = changes.dig("publisher_obj")
pub = changes&.dig("publisher")
pub_obj = changes&.dig("publisher_obj")

if params&.dig(:publisher) == "true"
changes[:publisher] =
if pub_obj
changes[:publisher] = pub_obj
else
changes[:publisher] = action == "update" ? [{ "name": pub[0] }, { "name": pub[1] }] : { "name": pub }
end
if pub_obj
changes[:publisher] = pub_obj
else
changes[:publisher] = action == "update" ? [{ "name": pub[0] }, { "name": pub[1] }] : { "name": pub }
end
else
if pub_obj
changes[:publisher] = action == "update" ? [pub_obj[0]["name"], pub_obj[1]["name"]] : pub_obj["name"]
Expand Down

0 comments on commit 87cb73b

Please sign in to comment.