Skip to content

Commit

Permalink
Linecount: Fix displaying total lines for user pages (smogon#9791)
Browse files Browse the repository at this point in the history
  • Loading branch information
Karthik99999 authored Sep 20, 2023
1 parent 691538a commit f69d139
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions server/chat-plugins/chatlog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -615,20 +615,17 @@ export abstract class Searcher {
buf += LogViewer.error(`Logs for month '${month}' do not exist on room ${roomid}.`);
return buf;
} else if (user) {
let total = 0;
for (const day in results) {
if (isNaN(results[day][user])) continue;
total += results[day][user];
}
buf += `<br />Total linecount: ${total}<hr />`;
buf += '<ol>';
buf += '<hr /><ol>';
const sortedDays = Utils.sortBy(Object.keys(results), day => ({reverse: day}));
let total = 0;
for (const day of sortedDays) {
const dayResults = results[day][user];
if (isNaN(dayResults)) continue;
total += dayResults;
buf += `<li>[<a roomid="view-chatlog-${roomid}--${day}">${day}</a>]: `;
buf += `${Chat.count(dayResults, 'lines')}</li>`;
}
buf = buf.replace('{total}', `${total}`);
} else {
buf += '<hr /><ol>';
// squish the results together
Expand Down

0 comments on commit f69d139

Please sign in to comment.