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

@ -116,6 +116,14 @@ router.get('/viewer', (req, res) => {
});
});
// renamed on Twitch: move the StreamElements-imported watch time to the new name (and remember it for re-imports)
router.post('/viewer/rename', (req, res) => {
try {
const to = seimport.rename(req.body.from, req.body.to);
res.redirect('/stats/viewer?q=' + encodeURIComponent(to));
} catch (e) { res.redirect('/stats?msg=' + encodeURIComponent('Rename failed: ' + e.message)); }
});
// removal request: forget a viewer completely (stats, watch time, raw chat; activity log entries too)
router.post('/viewer/forget', (req, res) => {
const login = String(req.body.login || '').toLowerCase(), id = String(req.body.user_id || '');