<p></p>
<p><b>@grekko</b> commented on this pull request.</p>
<hr>
<p>In <a href="https://github.com/openstreetmap/openstreetmap-website/pull/4481#discussion_r1481800377">lib/tasks/migrate_notes.rake</a>:</p>
<pre style='color:#555'>> + desc "Backfills notes-columns `body`, `author_ip` and `author_id`"
+ task :migrate_notes => :environment do
+ scope = Note.where(:body => nil, :author => nil, :author_ip => nil)
+ total_count = scope.count
+ remaining_count = total_count
+ puts "A total of #{total_count} Note-records have to be migrated."
+
+ # NB: default batch size is 1000
+ scope.find_in_batches do |batch|
+ puts "Processing batch of #{batch.size} records."
+ batch.each do |record|
+ opened_comment = record.comments.unscope(:where => :visible).find_by(:event => "opened")
+ (putc "x" && next) unless opened_comment
+
+ attributes = opened_comment.attributes.slice(*%w[body author_id author_ip]).compact_blank
+ record.update_columns(attributes) # rubocop:disable Rails/SkipsModelValidations
</pre>
<blockquote>
<p dir="auto">Situation A is before we do anything - no body, two comments. At the end of the project, we're aiming for situation C.</p>
</blockquote>
<p dir="auto">correct.</p>
<p dir="auto">Thanks for the test, that made it easy to spot the error 👍🏽 <code class="notranslate">Note#build_comments_with_extra_open_comment</code> needs not to check wether the migration was performed – Situation B – but needs to check wether the <code class="notranslate">open</code>-comment was removed – Situation C.</p>
<p dir="auto">See <a class="commit-link" data-hovercard-type="commit" data-hovercard-url="https://github.com/openstreetmap/openstreetmap-website/commit/d09085eac27360b8fe5f469028f3d221f444ba3b/hovercard" href="https://github.com/openstreetmap/openstreetmap-website/commit/d09085eac27360b8fe5f469028f3d221f444ba3b"><tt>d09085e</tt></a></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/4481#discussion_r1481800377">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/AAK2OLPN4D4XMBST4L3WQADYSOW3JAVCNFSM6AAAAABB4FLGOWVHI2DSMVQWIX3LMV43YUDVNRWFEZLROVSXG5CSMV3GSZLXHMYTQNRYGMZTAOJQGQ">unsubscribe</a>.<br />You are receiving this because you are subscribed to this thread.<img src="https://github.com/notifications/beacon/AAK2OLPCOB7ZYUWI4NYQEU3YSOW3JA5CNFSM6AAAAABB4FLGOWWGG33NNVSW45C7OR4XAZNRKB2WY3CSMVYXKZLTORJGK5TJMV32UY3PNVWWK3TUL5UWJTTPLR3ZQ.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/4481/review/1868330904</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/4481#discussion_r1481800377",
"url": "https://github.com/openstreetmap/openstreetmap-website/pull/4481#discussion_r1481800377",
"name": "View Pull Request"
},
"description": "View this Pull Request on GitHub",
"publisher": {
"@type": "Organization",
"name": "GitHub",
"url": "https://github.com"
}
}
]</script>