[openstreetmap/openstreetmap-website] Copies notes details from first comments to notes table (PR #5667)

Nenad Vujicic notifications at github.com
Thu Feb 20 10:02:50 UTC 2025


@nenad-vujicic commented on this pull request.



> +      note_ids = notes.pluck(:id)
+
+      sql_query = <<-SQL.squish
+        WITH first_comment AS(
+          SELECT DISTINCT ON (note_id) *
+          FROM note_comments
+          WHERE note_id BETWEEN #{note_ids.min} AND #{note_ids.max}
+          ORDER BY note_id, id
+        )
+        UPDATE notes
+        SET description = first_comment.body,
+            user_id = first_comment.author_id,
+            user_ip = first_comment.author_ip
+        FROM first_comment
+        WHERE first_comment.note_id = notes.id
+          AND first_comment.event = 'opened';

We have proposal for supporting notes with a missing opening comment (and generally all comments) in #5712. Do we have other special cases we should support before this?

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

Message ID: <openstreetmap/openstreetmap-website/pull/5667/review/2629335950 at github.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/rails-dev/attachments/20250220/d70af214/attachment-0001.htm>


More information about the rails-dev mailing list