feat(playevents): add Writer with start/end/skipped/synthetic paths

Owns the auto-close-prior step (caps each user at one open row),
spec §6 skip classification rule on play_ended (AND of completion <
0.5 and duration_played < 30s), and skip_events row writes. Synthetic
completed play wires the Subsonic /rest/scrobble?submission=true path
into the same store as native events.
This commit is contained in:
2026-04-25 22:32:33 -04:00
parent 73d3962fff
commit 0c7e1b0408
9 changed files with 563 additions and 7 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
// Code generated by sqlc. DO NOT EDIT.
// versions:
// sqlc v1.27.0
// sqlc v1.31.1
// source: albums.sql
package dbq
+1 -1
View File
@@ -1,6 +1,6 @@
// Code generated by sqlc. DO NOT EDIT.
// versions:
// sqlc v1.27.0
// sqlc v1.31.1
// source: artists.sql
package dbq
+1 -1
View File
@@ -1,6 +1,6 @@
// Code generated by sqlc. DO NOT EDIT.
// versions:
// sqlc v1.27.0
// sqlc v1.31.1
package dbq
+35 -1
View File
@@ -1,6 +1,6 @@
// Code generated by sqlc. DO NOT EDIT.
// versions:
// sqlc v1.27.0
// sqlc v1.31.1
package dbq
@@ -29,6 +29,31 @@ type Artist struct {
UpdatedAt pgtype.Timestamptz
}
type PlayEvent struct {
ID pgtype.UUID
UserID pgtype.UUID
TrackID pgtype.UUID
SessionID pgtype.UUID
StartedAt pgtype.Timestamptz
EndedAt pgtype.Timestamptz
DurationPlayedMs *int32
CompletionRatio *float64
WasSkipped bool
ClientID *string
SessionVectorAtPlay []byte
ScrobbledAt pgtype.Timestamptz
}
type PlaySession struct {
ID pgtype.UUID
UserID pgtype.UUID
StartedAt pgtype.Timestamptz
EndedAt pgtype.Timestamptz
LastEventAt pgtype.Timestamptz
TrackCount int32
ClientID *string
}
type Session struct {
ID pgtype.UUID
UserID pgtype.UUID
@@ -38,6 +63,15 @@ type Session struct {
LastSeenAt pgtype.Timestamptz
}
type SkipEvent struct {
ID pgtype.UUID
UserID pgtype.UUID
TrackID pgtype.UUID
SessionID pgtype.UUID
SkippedAt pgtype.Timestamptz
PositionMs int32
}
type Track struct {
ID pgtype.UUID
Title string
+1 -1
View File
@@ -1,6 +1,6 @@
// Code generated by sqlc. DO NOT EDIT.
// versions:
// sqlc v1.27.0
// sqlc v1.31.1
// source: sessions.sql
package dbq
+1 -1
View File
@@ -1,6 +1,6 @@
// Code generated by sqlc. DO NOT EDIT.
// versions:
// sqlc v1.27.0
// sqlc v1.31.1
// source: tracks.sql
package dbq
+1 -1
View File
@@ -1,6 +1,6 @@
// Code generated by sqlc. DO NOT EDIT.
// versions:
// sqlc v1.27.0
// sqlc v1.31.1
// source: users.sql
package dbq