<h2 dir="auto">Why are the changes necessary?</h2>
<p dir="auto">Addresses <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="1482565414" data-permission-text="Title is private" data-url="https://github.com/openstreetmap/openstreetmap-website/issues/3831" data-hovercard-type="issue" data-hovercard-url="/openstreetmap/openstreetmap-website/issues/3831/hovercard" href="https://github.com/openstreetmap/openstreetmap-website/issues/3831">#3831</a> which describes how a set of bugs related to the current <code class="notranslate">Note</code>-model can be solved by merging the "special first comment" into the <code class="notranslate">Note</code>-record itself.</p>
<p dir="auto"><em>This PR is meant to serve as a discussion starter. I gave my best to make sure the code changes are not introducing any undesired behavioural changes, but I am sure there are things I've missed, so please regard this PR a work in progress.</em></p>
<h2 dir="auto">What has changed?</h2>
<ul dir="auto">
<li>Adjusted the <code class="notranslate">Note</code>-Model to hold the new information about <code class="notranslate">body</code> and the <code class="notranslate">author</code>
<ul dir="auto">
<li>Added db fields <code class="notranslate">notes.{body,author_id,author_ip}</code> for that</li>
<li>Added <code class="notranslate">Note#comments_with_extra_open_comment</code> for the API to keep existing behaviour as it is</li>
</ul>
</li>
<li>Adjusts Web Controller and View code to work with the new <code class="notranslate">Note</code>-Model</li>
</ul>
<h2 dir="auto">Open Questions</h2>
<p dir="auto">a) Should the data migration (to backfill the <code class="notranslate">notes.{body,author_id,author_ip}</code> run in the scope of the migration or can this be a rake task which is running in the background and allows to perform some sanity checks on the data?</p>
<p dir="auto">b) I am making the assumption that the backfilling process can be performed for all <code class="notranslate">Note</code>-records. Does that hold true, so that eventually all <code class="notranslate">Note</code>-records will have a non-empty <code class="notranslate">body</code>-field or do we need to account for <code class="notranslate">Note</code>-records without a <code class="notranslate">body</code>?</p>
<h2 dir="auto">Open TODOs</h2>
<p dir="auto">I am not sure if I successfully migrated the logic of <code class="notranslate">Api::NotesController#feed</code>. I understand that at least the behaviour of the <code class="notranslate">.limit(result_limit)</code>-call will involuntarily return more results than it currently does. This part of the PR needs more focus and probably I'll have to add some tests first.</p>

<hr>

<h4>You can view, comment on, or merge this pull request online at:</h4>
<p>  <a href='https://github.com/openstreetmap/openstreetmap-website/pull/4481'>https://github.com/openstreetmap/openstreetmap-website/pull/4481</a></p>

<h4>Commit Summary</h4>
<ul>
  <li><a href="https://github.com/openstreetmap/openstreetmap-website/pull/4481/commits/69b872261738a69003e2023eeca7b5fb8bca1f26" class="commit-link">69b8722</a>  Extend Note with body & author, update controllers & views</li>
  <li><a href="https://github.com/openstreetmap/openstreetmap-website/pull/4481/commits/edfacccc2d69576884a6759f2a0967a428ede616" class="commit-link">edfaccc</a>  Update Tests to reflect Note refactoring</li>
  <li><a href="https://github.com/openstreetmap/openstreetmap-website/pull/4481/commits/c48393da2a1497fe6077e5d4cafc396b65e8cda7" class="commit-link">c48393d</a>  Add migration task for Notes</li>
</ul>

<h4 style="display: inline-block">File Changes </h4> <p style="display: inline-block">(<a href="https://github.com/openstreetmap/openstreetmap-website/pull/4481/files">25 files</a>)</p>
<ul>
  <li>
    <strong>M</strong>
    <a href="https://github.com/openstreetmap/openstreetmap-website/pull/4481/files#diff-6e9fe051c0ef757618e376ffe731dfca8d4960ef0838b7d6a05609b46ba0fad1">app/controllers/api/notes_controller.rb</a>
    (54)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/openstreetmap/openstreetmap-website/pull/4481/files#diff-c254740097a8c0601832077488db77e572b2c2b926f77508fadc6081b0052804">app/controllers/notes_controller.rb</a>
    (3)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/openstreetmap/openstreetmap-website/pull/4481/files#diff-08ddccf408b18937e98b422e555eaf851c2a02c3ba815c5aeb8bc00efe65ecab">app/models/note.rb</a>
    (54)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/openstreetmap/openstreetmap-website/pull/4481/files#diff-0858cfa3782c0bba33f9908f6588bfebc08fd0af5a423b77bb5f4d35969f91b6">app/models/note_comment.rb</a>
    (1)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/openstreetmap/openstreetmap-website/pull/4481/files#diff-c7cc5e0ba0c88700d660c41be72e9922c680851b405ec2f74142c3bd3d5cf19c">app/views/api/notes/_description.html.erb</a>
    (2)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/openstreetmap/openstreetmap-website/pull/4481/files#diff-a14835243072d71830ba15ff480de24e3146811fabdf73b7e35670af209fbf05">app/views/api/notes/_note.json.jbuilder</a>
    (2)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/openstreetmap/openstreetmap-website/pull/4481/files#diff-9b8b3e6d46a2a808a27e4c2f8d88c5470d39ee77146f8bb530124c0cacc35dbe">app/views/api/notes/_note.rss.builder</a>
    (2)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/openstreetmap/openstreetmap-website/pull/4481/files#diff-143dab9bcdf18ed43c02d5c815e4fb922faf69c55a45c4c8af8c7cb07af310e9">app/views/api/notes/_note.xml.builder</a>
    (2)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/openstreetmap/openstreetmap-website/pull/4481/files#diff-4fe647349351c7492508c788230b91b7f4445d4b821f6781ac7fcfad5e879f21">app/views/notes/index.html.erb</a>
    (2)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/openstreetmap/openstreetmap-website/pull/4481/files#diff-84d04c9c37a8be927ab1870e6b3c1940f670585b77b8e88c32d6ded35cf87dc7">app/views/notes/show.html.erb</a>
    (6)
  </li>
  <li>
    <strong>A</strong>
    <a href="https://github.com/openstreetmap/openstreetmap-website/pull/4481/files#diff-c5c963a2c291a82c3b759506bbe2c7e1c6717a6d4e1490d3673363e88800de71">db/migrate/20240107144209_add_author_and_body_to_notes.rb</a>
    (33)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/openstreetmap/openstreetmap-website/pull/4481/files#diff-1dd5a8f580b9615769ddc19a64a98f455d9d20eb149c443f41d9d3c797d39b12">db/structure.sql</a>
    (14)
  </li>
  <li>
    <strong>A</strong>
    <a href="https://github.com/openstreetmap/openstreetmap-website/pull/4481/files#diff-0a68f1e832c2b927d8cbbc77d6bed16bcf589073d62bc2836a5b0f9daa1aefe2">lib/tasks/migrate_notes.rake</a>
    (24)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/openstreetmap/openstreetmap-website/pull/4481/files#diff-b4cc80ae5a4279eef2a7494cb8c489220ce03acaf36932b2042247df9d316908">test/controllers/api/notes_controller_test.rb</a>
    (258)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/openstreetmap/openstreetmap-website/pull/4481/files#diff-b41a560e061b578bbf13158bf175036a9489241ab69f59137c44d57df9682fa7">test/controllers/notes_controller_test.rb</a>
    (28)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/openstreetmap/openstreetmap-website/pull/4481/files#diff-98398a8a1dab8650c77983ee32006ee5d085b23e9108b6d995307112327009b0">test/factories/note_comments.rb</a>
    (2)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/openstreetmap/openstreetmap-website/pull/4481/files#diff-e5faca18e5e52daf20d8ffd5f110da070f121d1a9d07794e08f4522ffe45c6a5">test/factories/notes.rb</a>
    (11)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/openstreetmap/openstreetmap-website/pull/4481/files#diff-6a032d21d79d2213205dd62e5c08e7c92178c3a70a68c9c792f9398c4d5f9895">test/helpers/issues_helper_test.rb</a>
    (4)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/openstreetmap/openstreetmap-website/pull/4481/files#diff-7fbf0e6c10deff5d707995df2d2d9d1eced8fd6d9d23a1fac4818aae7e28bd2f">test/models/issue_test.rb</a>
    (4)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/openstreetmap/openstreetmap-website/pull/4481/files#diff-b93fe6b2fae5309f99ba81772f10cf26c2d05ce9eb923b430a03de6121951964">test/models/note_test.rb</a>
    (48)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/openstreetmap/openstreetmap-website/pull/4481/files#diff-74c3414af0a76b3935f1a316c51c37b9415ded1fd811d596ba523d38e7c1489b">test/system/index_test.rb</a>
    (8)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/openstreetmap/openstreetmap-website/pull/4481/files#diff-1937855845d794c2ab6ec4812a8b4e3230c470b69ff763285bdd810915042839">test/system/issues_test.rb</a>
    (2)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/openstreetmap/openstreetmap-website/pull/4481/files#diff-960e6e9200fa7ea5eed049f5de24d807cf7c7a4c0434875d23139ff261ddc0fe">test/system/note_comments_test.rb</a>
    (6)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/openstreetmap/openstreetmap-website/pull/4481/files#diff-8358a7e67a0668bb274231cf66a04040514feaf99359175ea3b51a8306979081">test/system/report_note_test.rb</a>
    (8)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/openstreetmap/openstreetmap-website/pull/4481/files#diff-57c59e735efb356e2a24b9fb26199792d98a0749cf882be51d34ba637c9ebcfa">test/system/report_user_test.rb</a>
    (4)
  </li>
</ul>

<h4>Patch Links:</h4>
<ul>
  <li><a href='https://github.com/openstreetmap/openstreetmap-website/pull/4481.patch'>https://github.com/openstreetmap/openstreetmap-website/pull/4481.patch</a></li>
  <li><a href='https://github.com/openstreetmap/openstreetmap-website/pull/4481.diff'>https://github.com/openstreetmap/openstreetmap-website/pull/4481.diff</a></li>
</ul>

<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">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/AAK2OLP3VDOYAW2NX4WCWDDYOX7SZAVCNFSM6AAAAABB4FLGOWVHI2DSMVQWIX3LMV43ASLTON2WKOZSGA4DGMBQGM2TOMQ">unsubscribe</a>.<br />You are receiving this because you are subscribed to this thread.<img src="https://github.com/notifications/beacon/AAK2OLNSGENS7SJMQ6MZRBTYOX7SZA5CNFSM6AAAAABB4FLGOWWGG33NNVSW45C7OR4XAZNFJFZXG5LFVJRW63LNMVXHIX3JMTHHYKA4WQ.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</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",
"url": "https://github.com/openstreetmap/openstreetmap-website/pull/4481",
"name": "View Pull Request"
},
"description": "View this Pull Request on GitHub",
"publisher": {
"@type": "Organization",
"name": "GitHub",
"url": "https://github.com"
}
}
]</script>