<p></p>
<p><b>@gravitystorm</b> commented on this pull request.</p>
<p dir="auto">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 <code class="notranslate">all_comments.drop(1)</code> for example, since that won't work after the next migration has completed.</p><hr>
<p>In <a href="https://github.com/openstreetmap/openstreetmap-website/pull/5667#discussion_r1957100379">db/migrate/20250212160355_backfill_note_descriptions.rb</a>:</p>
<pre style='color:#555'>> + 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';
</pre>
<p dir="auto">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 <code class="notranslate">all_comments.first</code> without any similar restriction.</p>
<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">—<br />Reply to this email directly, <a href="https://github.com/openstreetmap/openstreetmap-website/pull/5667#pullrequestreview-2619389133">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/AAK2OLLLCG444GQDZB7X5ST2P4T3XAVCNFSM6AAAAABXCOPTA2VHI2DSMVQWIX3LMV43YUDVNRWFEZLROVSXG5CSMV3GSZLXHMZDMMJZGM4DSMJTGM">unsubscribe</a>.<br />You are receiving this because you are subscribed to this thread.<img src="https://github.com/notifications/beacon/AAK2OLNPC3TBPDMPSIUG2AD2P4T3XA5CNFSM6AAAAABXCOPTA2WGG33NNVSW45C7OR4XAZNRKB2WY3CSMVYXKZLTORJGK5TJMV32UY3PNVWWK3TUL5UWJTU4EC2M2.gif" height="1" width="1" alt="" /><span style="color: transparent; font-size: 0; display: none; visibility: hidden; overflow: hidden; opacity: 0; width: 0; height: 0; max-width: 0; max-height: 0; mso-hide: all">Message ID: <span><openstreetmap/openstreetmap-website/pull/5667/review/2619389133</span><span>@</span><span>github</span><span>.</span><span>com></span></span></p>
<script type="application/ld+json">[
{
"@context": "http://schema.org",
"@type": "EmailMessage",
"potentialAction": {
"@type": "ViewAction",
"target": "https://github.com/openstreetmap/openstreetmap-website/pull/5667#pullrequestreview-2619389133",
"url": "https://github.com/openstreetmap/openstreetmap-website/pull/5667#pullrequestreview-2619389133",
"name": "View Pull Request"
},
"description": "View this Pull Request on GitHub",
"publisher": {
"@type": "Organization",
"name": "GitHub",
"url": "https://github.com"
}
}
]</script>