feat(import): keep the artist and the time of plays of artists I do not have
The plays of songs that are not in the library were only counted. Now, when such a play counts as listened (not a skip, long enough), its artist and its time are kept in a new table (migration 0031, outside_plays), so a model can later learn which artists are played together, also those not in the library. No title, album, IP address, country or platform is stored. The same play is kept once however many times the export is imported, and the report says how many were kept (history.kept_outside).
This commit is contained in:
parent
01cbab21be
commit
3ba087bcc5
2 changed files with 314 additions and 28 deletions
12
migrations/postgres/0031_outside_plays.sql
Normal file
12
migrations/postgres/0031_outside_plays.sql
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
-- PostgreSQL flavour of sqlite/0031_outside_plays.sql.
|
||||
|
||||
CREATE TABLE outside_plays (
|
||||
user_id BIGINT NOT NULL REFERENCES users(id) ON DELETE CASCADE,
|
||||
idempotency_key TEXT NOT NULL,
|
||||
artist TEXT NOT NULL,
|
||||
artist_key TEXT NOT NULL,
|
||||
played_at BIGINT NOT NULL,
|
||||
PRIMARY KEY (user_id, idempotency_key)
|
||||
);
|
||||
|
||||
CREATE INDEX idx_outside_plays_time ON outside_plays(user_id, played_at);
|
||||
15
migrations/sqlite/0031_outside_plays.sql
Normal file
15
migrations/sqlite/0031_outside_plays.sql
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
-- The plays of artists a person has no music of, brought in by an import: only the name of the artist and the time,
|
||||
-- enough to learn which artists are played in the same sitting (see internal/affinity). No title, album, IP address,
|
||||
-- country or platform is kept. A play that is later matched to a song of the library is left out of the learning
|
||||
-- (its listening event is there) and removed the next time the model is built.
|
||||
|
||||
CREATE TABLE outside_plays (
|
||||
user_id INTEGER NOT NULL REFERENCES users(id) ON DELETE CASCADE,
|
||||
idempotency_key TEXT NOT NULL, -- the key of the same play as a listening event, so it is told apart from it
|
||||
artist TEXT NOT NULL,
|
||||
artist_key TEXT NOT NULL, -- storage.SearchKey of the name: how it meets the artists of the library
|
||||
played_at INTEGER NOT NULL, -- unix seconds
|
||||
PRIMARY KEY (user_id, idempotency_key)
|
||||
);
|
||||
|
||||
CREATE INDEX idx_outside_plays_time ON outside_plays(user_id, played_at);
|
||||
Loading…
Reference in a new issue