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

Tom Hughes notifications at github.com
Sat Feb 15 14:55:58 UTC 2025


@tomhughes 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';

I was trying to be safe ad make sure that if we have any "weird" notes with a missing open comment that we wouldn't (in my opinion wrongly) migrate that comment to be the primary note description.

I've just done some checking and we do indeed have just under a thousand such notes, all from 2016-2017, and mostly with just a "closed" comment and nothing else. In that case I suggest we're better off not making the person that closed it into the opener.

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

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


More information about the rails-dev mailing list