feat(import): an Import page, with the numbers of every import kept

The report of an import used to be shown once in Settings and lost. Each
import is now stored (migration 0030, spotify_imports) as the report in
JSON, and GET /me/import/spotify lists the past ones, newest first.
POST /me/import/spotify answers with the same shape plus id and created_at.

The web app gets an Import page (menu, More tab) with the form and one card
for each past import: plays read, added, already there, not in the library,
the playlists it made and the artists that are missing. Settings only links
to it. An import that finds nothing is not kept, and a report that cannot be
stored is still returned to the person who asked.
This commit is contained in:
tgiachi 2026-11-15 10:34:12 +01:00
commit aa4883b955
2 changed files with 868 additions and 154 deletions

View file

@ -0,0 +1,10 @@
-- PostgreSQL flavour of sqlite/0030_spotify_imports.sql.
CREATE TABLE spotify_imports (
id BIGINT GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
user_id BIGINT NOT NULL REFERENCES users(id) ON DELETE CASCADE,
created_at BIGINT NOT NULL,
report TEXT NOT NULL
);
CREATE INDEX idx_spotify_imports_user ON spotify_imports(user_id, created_at DESC);

View file

@ -0,0 +1,11 @@
-- What each import of a Spotify export did, kept so the numbers can be read again later: the report as JSON (see
-- internal/spotifyimport). The files themselves are never kept.
CREATE TABLE spotify_imports (
id INTEGER PRIMARY KEY,
user_id INTEGER NOT NULL REFERENCES users(id) ON DELETE CASCADE,
created_at INTEGER NOT NULL, -- unix seconds
report TEXT NOT NULL
);
CREATE INDEX idx_spotify_imports_user ON spotify_imports(user_id, created_at DESC);