Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[alias]
sqlx = ["bin", "sqlx"]
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,5 @@
*.db-shm
*.db-wal
*.log

.bin/
5 changes: 5 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,8 @@ serde_json = "1.0.79"
sqlx = { version = "0.5.11", features = [ "runtime-tokio-rustls", "chrono", "sqlite" ] }
tempfile = "3.3.0"
tokio = { version = "1.17.0", features = [ "full" ] }

[package.metadata.bin]
sqlx-cli = { version = "0.5.11", locked = true, bins = [
"sqlx",
] }
1 change: 1 addition & 0 deletions migrations/20251027172000_add_metabrainz_id.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ALTER TABLE scrobbles ADD COLUMN mbid TEXT DEFAULT NULL;
5 changes: 3 additions & 2 deletions src/data/db/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,14 +91,15 @@ async fn insert_scrobble(scrobble: SavedScrobble, pool: &SqlitePool) -> Result<i

let id = sqlx::query!(
r#"
INSERT INTO scrobbles (track, artist, album, loved, timestamp_utc)
VALUES (?1, ?2, ?3, ?4, ?5)
INSERT INTO scrobbles (track, artist, album, loved, timestamp_utc, mbid)
VALUES (?1, ?2, ?3, ?4, ?5, ?6)
"#,
scrobble.title,
scrobble.artist,
scrobble.album,
scrobble.loved,
scrobble.timestamp_utc,
scrobble.mbid,
)
.execute(&mut conn)
.await?
Expand Down
5 changes: 5 additions & 0 deletions src/models/saved_scrobbles.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ pub struct SavedScrobble {
pub loved: bool,
pub datetime_local: DateTime<Local>,
pub timestamp_utc: i64,
pub mbid: Option<String>,
}

impl SavedScrobble {
Expand All @@ -139,6 +140,10 @@ impl SavedScrobble {
loved: scrobble.loved(),
datetime_local: scrobble.date().datetime_local(),
timestamp_utc: scrobble.date().time_stamp(),
mbid: match scrobble.mbid.is_empty() {
true => None,
false => Some(scrobble.mbid.clone()),
},
}
}

Expand Down