<p></p>
<p><b>@tomhughes</b> requested changes on this pull request.</p>
<p dir="auto">I don't think we need to delay this - the counts should reflect what the links currently do and if we change what they do then we can consider how to deal with the counts then.</p>
<p dir="auto">Other than the specific comments I have added please adjust the commit message as per my comments on <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="2338457185" data-permission-text="Title is private" data-url="https://github.com/openstreetmap/openstreetmap-website/issues/4881" data-hovercard-type="pull_request" data-hovercard-url="/openstreetmap/openstreetmap-website/pull/4881/hovercard" href="https://github.com/openstreetmap/openstreetmap-website/pull/4881">#4881</a>.</p><hr>
<p>In <a href="https://github.com/openstreetmap/openstreetmap-website/pull/4875#discussion_r1629984530">db/migrate/20240605134916_add_notes_and_diary_comments_counter_caches.rb</a>:</p>
<pre style='color:#555'>> @@ -0,0 +1,6 @@
+class AddNotesAndDiaryCommentsCounterCaches < ActiveRecord::Migration[7.1]
+ def change
+ add_column :users, :diary_comments_count, :integer, :default => 0
+ add_column :users, :note_comments_count, :integer, :default => 0
</pre>
<p dir="auto">These need to call <code class="notranslate">reset_counters</code> for any user that already has comments or the counts won't be correct - see <code class="notranslate">db/migrate/20121005195010_add_diary_entry_counter_caches.rb</code> for a way to to it reasonably efficiently.</p>
<p dir="auto">There are less than 10k users with diary comments so that is probably fine but there are nearly half a million with not comments which may prove to be a problem in terms of time take to run the migration and populate the counters to we might have to do it with a rake task rather than in the migration.</p>
<hr>
<p>In <a href="https://github.com/openstreetmap/openstreetmap-website/pull/4875#discussion_r1629987200">app/views/users/show.html.erb</a>:</p>
<pre style='color:#555'>> @@ -11,21 +11,23 @@
<ul class='clearfix'>
<li>
<%= link_to t(".my edits"), :controller => "changesets", :action => "index", :display_name => current_user.display_name %>
- <span class='badge count-number'><%= number_with_delimiter(current_user.changesets.size) %></span>
+ <span class='badge count-number'><%= number_with_delimiter(current_user.changesets_count) %></span>
</pre>
<p dir="auto">Doesn't <code class="notranslate">changesets.size</code> already delegate to the counter? If it doesn't then this isn't working at the moment, which isn't good, and if it does why the change - what is the canonical rails way to do this?</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/4875#pullrequestreview-2102746814">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/AAK2OLK22GCYVMCJYR2DSVLZGCPIRAVCNFSM6AAAAABIYGPCSWVHI2DSMVQWIX3LMV43YUDVNRWFEZLROVSXG5CSMV3GSZLXHMZDCMBSG42DMOBRGQ">unsubscribe</a>.<br />You are receiving this because you are subscribed to this thread.<img src="https://github.com/notifications/beacon/AAK2OLP5ZSB27XQMYMH4SKLZGCPIRA5CNFSM6AAAAABIYGPCSWWGG33NNVSW45C7OR4XAZNRKB2WY3CSMVYXKZLTORJGK5TJMV32UY3PNVWWK3TUL5UWJTT5KVPL4.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/4875/review/2102746814</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/4875#pullrequestreview-2102746814",
"url": "https://github.com/openstreetmap/openstreetmap-website/pull/4875#pullrequestreview-2102746814",
"name": "View Pull Request"
},
"description": "View this Pull Request on GitHub",
"publisher": {
"@type": "Organization",
"name": "GitHub",
"url": "https://github.com"
}
}
]</script>