<p></p>
<blockquote>
<p dir="auto">Besides the <a href="https://github.com/openstreetmap/openstreetmap-website/pull/5255#discussion_r1801064970" data-hovercard-type="pull_request" data-hovercard-url="/openstreetmap/openstreetmap-website/pull/5255/hovercard">double-join db query</a>, there's couple more issues with the interaction type: <a href="https://github.com/openstreetmap/openstreetmap-website/pull/4700#issuecomment-2221682594" data-hovercard-type="pull_request" data-hovercard-url="/openstreetmap/openstreetmap-website/pull/4700/hovercard">"blue on blue" colors</a> and whether the submitted/commented classification makes sense at all (what if I closed a note without a comment?). I wanted to try opened/closed/commented instead.</p>
</blockquote>
<p dir="auto">First of all, thank you for taking time and effort reviewing this. Few things I would like to reassess:</p>
<ul dir="auto">
<li>Related to the commented/submitted criteria we could use <code class="notranslate">EXISTS</code> subqueries which removes the need for a double joins, potentially making the query simpler and more performant. I could try testing this in terms of performance with large number of mocked entries so we can better get the idea of how this would affect the performance.</li>
</ul>
<div class="highlight highlight-source-ruby" dir="auto"><pre class="notranslate"> <span class="pl-en">scope</span> <span class="pl-pds">:filter_by_note_type</span><span class="pl-kos">,</span> <span class="pl-en">lambda</span> <span class="pl-kos">{</span> |<span class="pl-s1">note_type</span><span class="pl-kos">,</span> <span class="pl-s1">user_id</span>|
<span class="pl-k">case</span> <span class="pl-s1">note_type</span>
<span class="pl-k">when</span> <span class="pl-s">"commented"</span>
<span class="pl-en">where</span><span class="pl-kos">(</span><span class="pl-s">"EXISTS (SELECT 1 FROM note_comments WHERE note_comments.note_id = notes.id AND (note_comments.author_id != ? OR note_comments.author_id IS NULL))"</span><span class="pl-kos">,</span> <span class="pl-s1">user_id</span><span class="pl-kos">)</span>
<span class="pl-k">when</span> <span class="pl-s">"submitted"</span>
<span class="pl-en">where</span><span class="pl-kos">(</span><span class="pl-s">"EXISTS (SELECT 1 FROM note_comments WHERE note_comments.note_id = notes.id AND note_comments.author_id = ? AND note_comments.id = (SELECT MIN(nc.id) FROM note_comments nc WHERE nc.note_id = notes.id))"</span><span class="pl-kos">,</span> <span class="pl-s1">user_id</span><span class="pl-kos">)</span>
<span class="pl-k">else</span>
<span class="pl-en">all</span>
<span class="pl-k">end</span>
<span class="pl-kos">}</span></pre></div>
<ul dir="auto">
<li>Regarding the open/closed/commented differentiation instead of commented/submitted - It makes sense to me too but I would also like to hear the <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/tomhughes/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/tomhughes">@tomhughes</a> <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/gravitystorm/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/gravitystorm">@gravitystorm</a> opinions on this too, so we could all sync on right approach for this.</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/5255#issuecomment-2426960898">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/AAK2OLK2WM6O2UEEO77QQDLZ4UKGPAVCNFSM6AAAAABPVCJ4ACVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDIMRWHE3DAOBZHA">unsubscribe</a>.<br />You are receiving this because you are subscribed to this thread.<img src="https://github.com/notifications/beacon/AAK2OLPTX6KCOU4BII4CMLTZ4UKGPA5CNFSM6AAAAABPVCJ4ACWGG33NNVSW45C7OR4XAZNMJFZXG5LFINXW23LFNZ2KUY3PNVWWK3TUL5UWJTUQVB6AE.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/5255/c2426960898</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/5255#issuecomment-2426960898",
"url": "https://github.com/openstreetmap/openstreetmap-website/pull/5255#issuecomment-2426960898",
"name": "View Pull Request"
},
"description": "View this Pull Request on GitHub",
"publisher": {
"@type": "Organization",
"name": "GitHub",
"url": "https://github.com"
}
}
]</script>