From 3bb44a08106ca38bb329e1244109b53fb64695cc Mon Sep 17 00:00:00 2001 From: mkelvers Date: Sun, 17 May 2026 16:45:56 +0200 Subject: [PATCH] feat: add updated_at to watchlist export --- templates/watchlist.gohtml | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/templates/watchlist.gohtml b/templates/watchlist.gohtml index 09c5177..2924b16 100644 --- a/templates/watchlist.gohtml +++ b/templates/watchlist.gohtml @@ -166,16 +166,24 @@ } function exportWatchlistCsv() { - const rows = Array.from(document.querySelectorAll('.watchlist-item')).map(function(item) { - return [ - item.dataset.malId || '', - item.dataset.title || item.querySelector('h3')?.textContent.trim() || '', - item.dataset.status || '', - ] - }) + const rows = Array.from(document.querySelectorAll('.watchlist-item')) + .sort(function(a, b) { + return parseInt(b.dataset.updatedAt || 0) - parseInt(a.dataset.updatedAt || 0) + }) + .map(function(item) { + const updatedAt = parseInt(item.dataset.updatedAt || 0) + const updatedAtISO = updatedAt > 0 ? new Date(updatedAt * 1000).toISOString() : '' + + return [ + item.dataset.malId || '', + item.dataset.title || item.querySelector('h3')?.textContent.trim() || '', + item.dataset.status || '', + updatedAtISO, + ] + }) const csv = [ - ['mal_id', 'title', 'status'], + ['mal_id', 'title', 'status', 'updated_at'], ...rows, ].map(function(row) { return row.map(csvEscape).join(',')