<p></p>
<p><b>@gravitystorm</b> commented on this pull request.</p>

<hr>

<p>In <a href="https://github.com/openstreetmap/openstreetmap-website/pull/4481#discussion_r1784897557">app/models/note.rb</a>:</p>
<pre style='color:#555'>> @@ -39,6 +49,10 @@ class Note < ApplicationRecord
 
   DEFAULT_FRESHLY_CLOSED_LIMIT = 7.days
 
+  def comments_with_extra_open_comment
</pre>
<blockquote>
<p dir="auto">I am not sure what you mean with that. The idea of <code class="notranslate">Note#comments_with_extra_open_comment</code> is to hide the logic inside the model and make it obvious to developers that this method returns something special.</p>
<p dir="auto">I've now added a <code class="notranslate">Note#api_comments</code>-method which should always return the full list of note comments including the <code class="notranslate">open</code>-comment</p>
</blockquote>
<p dir="auto">But the point I'm making is that this still leaks complexity out of the Note model. We should have:</p>
<ul dir="auto">
<li>Note#author</li>
<li>Note#body</li>
<li>Note#comments</li>
</ul>
<p dir="auto">That's all that both the web view and the API need. The web view can use them directly. The API can use the first two to make the legacy-first-comment.</p>
<p dir="auto">I can see that the web view has some things like <code class="notranslate">if @note.body_migrated?</code> but the view should not care about this.</p>
<p dir="auto">Now your point about the collection proxy object is a good one, and one I need to think about. Perhaps we can do something like (completely untested):</p>
<pre class="notranslate"><code class="notranslate">def comments
  if body_migrated?
    raw_comments
  else
    raw_comments.offset(1)
  end
end
</code></pre>
<p dir="auto">... to get a collection proxy either way.</p>
<p dir="auto">Partly this depends on the data migration strategy - whether we expect to do one of the two following options:</p>
<ul dir="auto">
<li>A migration that, for each note (and in a transaction) creates the body, author, and deletes the first comment</li>
<li>Two migrations, the first that backfills the body and author, and the second that deletes all the first comments. But that's extremely risky (imho) since the second migration is must-work-first-time.</li>
</ul>
<p dir="auto">Final point - there's still references to "opened comment" in the PR, but it's the "first comment" that we're focussing on.</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_r1784897557">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/AAK2OLJXQFEZNWHOOUZQ7D3ZZQQAVAVCNFSM6AAAAABB4FLGOWVHI2DSMVQWIX3LMV43YUDVNRWFEZLROVSXG5CSMV3GSZLXHMZDGNBTGUZDKNRQGI">unsubscribe</a>.<br />You are receiving this because you are subscribed to this thread.<img src="https://github.com/notifications/beacon/AAK2OLM3RRF2OMUK3INDSJLZZQQAVA5CNFSM6AAAAABB4FLGOWWGG33NNVSW45C7OR4XAZNRKB2WY3CSMVYXKZLTORJGK5TJMV32UY3PNVWWK3TUL5UWJTULV5OOE.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/2343525602</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_r1784897557",
"url": "https://github.com/openstreetmap/openstreetmap-website/pull/4481#discussion_r1784897557",
"name": "View Pull Request"
},
"description": "View this Pull Request on GitHub",
"publisher": {
"@type": "Organization",
"name": "GitHub",
"url": "https://github.com"
}
}
]</script>