[openstreetmap/openstreetmap-website] Add status filter to user's note page (PR #5297)

Emin Kocan notifications at github.com
Wed Nov 6 15:27:12 UTC 2024


@kcne commented on this pull request.



> @@ -34,6 +34,16 @@ class Note < ApplicationRecord
 
   scope :visible, -> { where.not(:status => "hidden") }
   scope :invisible, -> { where(:status => "hidden") }
+  scope :with_status, lambda { |status|
+    case status
+    when "open"
+      where(:status => "open")
+    when "closed"
+      where(:status => "closed")
+    else
+      all
+    end
+  }

Fixed and updated the PR. Since this is the only place using the scope, I removed it to simplify the code and maintain consistency. If a need arises, we can reintroduce it later.

Also, I’ve added a test in the controller to cover the basic status filtering functionality. Let me know if further tests are needed.

-- 
Reply to this email directly or view it on GitHub:
https://github.com/openstreetmap/openstreetmap-website/pull/5297#discussion_r1831242593
You are receiving this because you are subscribed to this thread.

Message ID: <openstreetmap/openstreetmap-website/pull/5297/review/2418659466 at github.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/rails-dev/attachments/20241106/53c6a28f/attachment-0001.htm>


More information about the rails-dev mailing list