Stats: move a renamed viewer's StreamElements watch time to their new name

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>
This commit is contained in:
Bashy 2026-11-22 18:10:00 +02:00
parent 3a312ab493
commit 5bf4bffaa0
3 changed files with 53 additions and 5 deletions

View file

@ -68,7 +68,16 @@
</table>
<% } %>
<form method="POST" action="/stats/viewer/forget" style="margin-top:1.5rem;">
<% 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;"