@gravitystorm commented on this pull request.
I would also interested in what the next step will be. How do you propose
removing the first comments, when they are no longer used? That migration will
need to work in an "online" manner, i.e. there needs to be code that runs
before the migration, during the migration and after the migration. How will
that code know if the first comment has been already deleted for a given note?
It can't just be `all_comments.drop(1)` for example, since that won't work
after the next migration has completed.
> + 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';
Why is this restricted to only comments with event = 'opened'? That's not the
same logic as is currently used for creating note descriptions using comments -
it uses `all_comments.first` without any similar restriction.
--
Reply to this email directly or view it on GitHub:
https://github.com/openstreetmap/openstreetmap-website/pull/5667#pullrequestreview-2619389133
You are receiving this because you are subscribed to this thread.
Message ID:
<openstreetmap/openstreetmap-website/pull/5667/review/2619389...@github.com>
_______________________________________________
rails-dev mailing list
rails-dev@openstreetmap.org
https://lists.openstreetmap.org/listinfo/rails-dev