From 2618a49b1f3c7834895e536cad3bc9cc803a99e2 Mon Sep 17 00:00:00 2001 From: Nenad Vujicic Date: Mon, 20 Jan 2025 13:15:03 +0100 Subject: [PATCH] Removes optional using first comments records Removes optional using of note's first comments records for retrieving note's description, author_id, author_ip in Note model file. --- app/models/note.rb | 37 ++++++------------------------------- 1 file changed, 6 insertions(+), 31 deletions(-) diff --git a/app/models/note.rb b/app/models/note.rb index 55d7826c1d..65e8ef365b 100644 --- a/app/models/note.rb +++ b/app/models/note.rb @@ -91,44 +91,19 @@ def freshly_closed_until closed_at + DEFAULT_FRESHLY_CLOSED_LIMIT end - # Return the note's description, unless record is unavailable and - # it will be derived from the first comment + # Return the note's description def description - if user_ip.nil? && user_id.nil? - comments.first.body - else - RichText.new("text", self[:description]) - end + RichText.new("text", self[:description]) end - # Return the note's author object, unless record is unavailable and - # it will be derived from the first comment - def author - if user_ip.nil? && user_id.nil? - comments.first.author - else - self[:author] - end - end - - # Return the note's author ID, unless record is unavailable and - # it will be derived from the first comment + # Return the note's author ID def author_id - if user_ip.nil? && user_id.nil? - comments.first.author_id - else - user_id - end + user_id end - # Return the note's author IP address, unless record is unavailable and - # it will be derived from the first comment + # Return the note's author IP address def author_ip - if user_ip.nil? && user_id.nil? - comments.first.author_ip - else - user_ip - end + user_ip end private