<p dir="auto">This PR refactors some database queries, to avoid using <code class="notranslate">_id</code> and use the relation names instead. Generally this involves changing <code class="notranslate">.where(user_id => u.id)</code> to <code class="notranslate">.where(user => u)</code> or similar. Sometimes the relation name is quite different from the underlying column (e.g. <code class="notranslate">gpx_id</code> => <code class="notranslate">trace</code>).</p>
<p dir="auto">Rails is pretty forgiving on whether you pass in an id or an object, so sometimes there's nothing to change on the right hand side.</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/4209'>https://github.com/openstreetmap/openstreetmap-website/pull/4209</a></p>

<h4>Commit Summary</h4>
<ul>
  <li><a href="https://github.com/openstreetmap/openstreetmap-website/pull/4209/commits/f5db9cbb207e17fc8a2f15f681819e9e55aa1906" class="commit-link">f5db9cb</a>  Avoid using _id in queries</li>
  <li><a href="https://github.com/openstreetmap/openstreetmap-website/pull/4209/commits/b595b87c48b59977304bf6c32e74c93d83cc0f8d" class="commit-link">b595b87</a>  Use trace instead of gpx_id in queries</li>
</ul>

<h4 style="display: inline-block">File Changes </h4> <p style="display: inline-block">(<a href="https://github.com/openstreetmap/openstreetmap-website/pull/4209/files">10 files</a>)</p>
<ul>
  <li>
    <strong>M</strong>
    <a href="https://github.com/openstreetmap/openstreetmap-website/pull/4209/files#diff-6726f8601cd22886963fb41888b55956cae4f8124aa12c701da77c3add44d94c">app/controllers/api/changesets_controller.rb</a>
    (2)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/openstreetmap/openstreetmap-website/pull/4209/files#diff-6e9fe051c0ef757618e376ffe731dfca8d4960ef0838b7d6a05609b46ba0fad1">app/controllers/api/notes_controller.rb</a>
    (2)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/openstreetmap/openstreetmap-website/pull/4209/files#diff-cf3fe9dc357f802fd9155582ffc8c6f71185065267991a2135323ad2d044b4f3">app/controllers/changesets_controller.rb</a>
    (6)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/openstreetmap/openstreetmap-website/pull/4209/files#diff-4b73866ef57c70fca07c0f330d7a57aae939b11e4aae0514f303df3aa3762f89">app/controllers/diary_entries_controller.rb</a>
    (4)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/openstreetmap/openstreetmap-website/pull/4209/files#diff-cc7acbfb990b45e6f8cb1fe65cbd081a7819b596b03e0ac2ef2e82a9537d3278">app/controllers/issues_controller.rb</a>
    (2)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/openstreetmap/openstreetmap-website/pull/4209/files#diff-e84e62745ba4aecd60082e63ab314406d4080ba1bdf207620a0ddcf5ab5850d1">app/controllers/user_roles_controller.rb</a>
    (2)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/openstreetmap/openstreetmap-website/pull/4209/files#diff-33e24e983f7ae5829e0e919c3843ccaaa05be35610607ec2fd486636d2c14e56">app/models/changeset.rb</a>
    (2)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/openstreetmap/openstreetmap-website/pull/4209/files#diff-49ff8e13eb2bff9ffd834dad7421f568b40186cb58b28e7eac6b3e9168ec8759">app/models/trace.rb</a>
    (10)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/openstreetmap/openstreetmap-website/pull/4209/files#diff-10a5c4533814c8b1222f0ef0833c82edd68584d85757fc431557b39813777c19">test/controllers/diary_entries_controller_test.rb</a>
    (6)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/openstreetmap/openstreetmap-website/pull/4209/files#diff-9fd2e1fe5658049094afe3aa0ab829848cd04fd0b3f62d56ad51b1ae40efdc2e">test/models/trace_test.rb</a>
    (6)
  </li>
</ul>

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