Viewer page (import-only viewers): 'Renamed on Twitch? New name -> Move'. Moves the imported minutes (adding to any already there) and stores old -> new in watch_alias, which importing again applies, so the hours never jump back to the old name. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
86 lines
5.5 KiB
Text
86 lines
5.5 KiB
Text
<style>
|
|
.meta { color:var(--pico-muted-color); font-size:.85rem; }
|
|
.card { border:1px solid var(--pico-muted-border-color); border-radius:12px; padding:.8rem 1rem; margin-bottom:1rem; }
|
|
.tiles { display:grid; grid-template-columns:repeat(auto-fit, minmax(140px, 1fr)); gap:.6rem; }
|
|
.tile { border:1px solid var(--pico-muted-border-color); border-radius:12px; padding:.6rem .8rem; }
|
|
.tile .v { font-size:1.5rem; font-weight:700; line-height:1.1; }
|
|
.tile .k { font-size:.8rem; color:var(--pico-muted-color); }
|
|
.parts { display:flex; flex-wrap:wrap; gap:.4rem; margin-top:.6rem; }
|
|
.part { border:1px solid var(--pico-muted-border-color); border-radius:99px; padding:.1rem .6rem; font-size:.8rem; }
|
|
.emotes { display:flex; flex-wrap:wrap; gap:.4rem; }
|
|
.emote { display:flex; align-items:center; gap:.3rem; border:1px solid var(--pico-muted-border-color); border-radius:99px; padding:.1rem .55rem .1rem .25rem; font-size:.8rem; }
|
|
.emote img { width:24px; height:24px; object-fit:contain; }
|
|
table { font-size:.85rem; }
|
|
.btn-sm { margin:0; padding:.25rem .7rem; font-size:.8rem; width:auto; }
|
|
</style>
|
|
|
|
<p><a href="/stats">← Stats</a></p>
|
|
<% if (!viewer) { %>
|
|
<h2><%= q %></h2>
|
|
<p class="meta">No statistics for this viewer (yet). Names are Twitch logins, e.g. <code>channel</code>.</p>
|
|
<% } else {
|
|
const hm = m => m >= 60 ? `${Math.floor(m / 60)} h ${m % 60} m` : `${m} m`;
|
|
const minutes = (viewer.watch.ticks || 0) * 5 + (viewer.importedMinutes || 0); %>
|
|
<h2 style="margin-bottom:.2rem;"><%= viewer.name %> <span class="meta">@<%= viewer.login %></span></h2>
|
|
<p class="meta"><%= viewer.level.name %>
|
|
<% if (viewer.hidden) { %> · <span class="badge badge-grey" title="In Settings → Hidden chatters: counted, but not shown in leaderboards">hidden bot</span><% } %>
|
|
<% if (viewer.chat.first_seen) { %> · first chat <%= viewer.chat.first_seen.slice(0, 10) %>, last <%= viewer.chat.last_seen.slice(0, 10) %><% } %>
|
|
</p>
|
|
|
|
<div class="card">
|
|
<div class="tiles">
|
|
<div class="tile"><div class="v"><%= viewer.total.toLocaleString() %></div><div class="k">points</div></div>
|
|
<div class="tile" title="<%= viewer.importedMinutes ? `includes ${hm(viewer.importedMinutes)} imported from StreamElements` : '' %>"><div class="v"><%= hm(minutes) %></div><div class="k">watched<%= viewer.importedMinutes ? ' · incl. StreamElements' : '' %></div></div>
|
|
<div class="tile"><div class="v"><%= (viewer.chat.messages || 0).toLocaleString() %></div><div class="k">chat messages</div></div>
|
|
<div class="tile"><div class="v"><%= viewer.checkins %></div><div class="k">check-ins</div></div>
|
|
</div>
|
|
<div class="parts" title="Where the points come from (values in docs/PLANS.md)">
|
|
<% for (const [k, v] of Object.entries(viewer.parts).sort((a, b) => b[1] - a[1])) { %><span class="part"><%= k %>: <strong><%= v.toLocaleString() %></strong></span><% } %>
|
|
</div>
|
|
</div>
|
|
|
|
<% if (viewer.emotes.length) { %>
|
|
<h4>Emotes</h4>
|
|
<div class="emotes" style="margin-bottom:1rem;">
|
|
<% for (const e of viewer.emotes) {
|
|
const src = e.source === 'twitch' && e.emote_id ? `https://static-cdn.jtvnw.net/emoticons/v2/${e.emote_id}/default/dark/1.0`
|
|
: e.source === '7tv' && e.emote_id ? `https://cdn.7tv.app/emote/${e.emote_id}/1x.webp` : null; %>
|
|
<span class="emote"><% if (src) { %><img src="<%= src %>" alt="" loading="lazy"><% } %><%= e.emote %> <strong><%= e.uses %></strong></span>
|
|
<% } %>
|
|
</div>
|
|
<% } %>
|
|
|
|
<% if (viewer.commands.length) { %>
|
|
<h4>Commands</h4>
|
|
<div class="emotes" style="margin-bottom:1rem;"><% for (const c of viewer.commands) { %><span class="emote" style="padding-left:.55rem;"><code><%= c.command %></code> <strong><%= c.uses %></strong></span><% } %></div>
|
|
<% } %>
|
|
|
|
<% if (viewer.actions.length) { %>
|
|
<h4>Actions</h4>
|
|
<table>
|
|
<thead><tr><th>Action</th><th>What</th><th>Times</th><th>Total</th><th>Last</th></tr></thead>
|
|
<tbody>
|
|
<% for (const a of viewer.actions) { %>
|
|
<tr><td><%= a.action.replace(/_/g, ' ') %></td><td><%= a.item %></td><td><%= a.uses %></td>
|
|
<td><%= a.unit ? `${(+a.amount).toLocaleString()} ${a.unit}` : '' %></td><td><small><%= (a.last_at || '').slice(0, 10) %></small></td></tr>
|
|
<% } %>
|
|
</tbody>
|
|
</table>
|
|
<% } %>
|
|
|
|
<% if (viewer.importedMinutes && !viewer.user_id) { %>
|
|
<form method="POST" action="/stats/viewer/rename" style="display:flex; gap:.5rem; align-items:center; flex-wrap:wrap; margin-top:1.5rem;"
|
|
title="This viewer is only known from the StreamElements import (by name). If they renamed on Twitch, their imported watch time moves to the new name, and importing again later applies the rename too.">
|
|
<input type="hidden" name="from" value="<%= viewer.login %>">
|
|
<span class="meta">Renamed on Twitch? New name:</span>
|
|
<input name="to" required pattern="@?\w{2,25}" placeholder="new Twitch login" style="width:14rem; margin:0; padding:.25rem .5rem; font-size:.85rem; height:auto;">
|
|
<button type="submit" class="outline btn-sm">Move</button>
|
|
</form>
|
|
<% } %>
|
|
<form method="POST" action="/stats/viewer/forget" style="margin-top:1rem;">
|
|
<input type="hidden" name="login" value="<%= viewer.login %>">
|
|
<input type="hidden" name="user_id" value="<%= viewer.user_id || '' %>">
|
|
<button type="button" data-confirm class="outline btn-sm" style="color:#f88; border-color:#f88;"
|
|
title="For removal requests: deletes all of this viewer's statistics, watch time, stored chat and activity-log entries. Cannot be undone.">Forget this viewer</button>
|
|
</form>
|
|
<% } %>
|