diff --git a/crates/pgpull/src/lib.rs b/crates/pgpull/src/lib.rs index 80557829..902ea8a9 100644 --- a/crates/pgpull/src/lib.rs +++ b/crates/pgpull/src/lib.rs @@ -1,5 +1,8 @@ use std::env; +mod repo; +mod xata; + use anyhow::Error; pub async fn pull_data() -> Result<(), Error> { diff --git a/crates/pgpull/src/repo/album.rs b/crates/pgpull/src/repo/album.rs new file mode 100644 index 00000000..e69de29b diff --git a/crates/pgpull/src/repo/artist.rs b/crates/pgpull/src/repo/artist.rs new file mode 100644 index 00000000..e69de29b diff --git a/crates/pgpull/src/repo/mod.rs b/crates/pgpull/src/repo/mod.rs new file mode 100644 index 00000000..627ee2f7 --- /dev/null +++ b/crates/pgpull/src/repo/mod.rs @@ -0,0 +1,6 @@ +pub mod album; +pub mod artist; +pub mod playlist; +pub mod scrobble; +pub mod track; +pub mod user; diff --git a/crates/pgpull/src/repo/playlist.rs b/crates/pgpull/src/repo/playlist.rs new file mode 100644 index 00000000..e69de29b diff --git a/crates/pgpull/src/repo/scrobble.rs b/crates/pgpull/src/repo/scrobble.rs new file mode 100644 index 00000000..e69de29b diff --git a/crates/pgpull/src/repo/track.rs b/crates/pgpull/src/repo/track.rs new file mode 100644 index 00000000..e69de29b diff --git a/crates/pgpull/src/repo/user.rs b/crates/pgpull/src/repo/user.rs new file mode 100644 index 00000000..e69de29b diff --git a/crates/pgpull/src/xata/album.rs b/crates/pgpull/src/xata/album.rs new file mode 100644 index 00000000..fca2adf2 --- /dev/null +++ b/crates/pgpull/src/xata/album.rs @@ -0,0 +1,21 @@ +use chrono::{DateTime, Utc}; +use serde::Deserialize; + +#[derive(Debug, sqlx::FromRow, Deserialize, Clone)] +pub struct Album { + pub xata_id: String, + pub title: String, + pub artist: String, + pub release_date: Option, + pub album_art: Option, + pub year: Option, + pub spotify_link: Option, + pub tidal_link: Option, + pub youtube_link: Option, + pub apple_music_link: Option, + pub sha256: String, + pub uri: Option, + pub artist_uri: Option, + #[serde(with = "chrono::serde::ts_seconds")] + pub xata_createdat: DateTime, +} diff --git a/crates/pgpull/src/xata/album_track.rs b/crates/pgpull/src/xata/album_track.rs new file mode 100644 index 00000000..124075aa --- /dev/null +++ b/crates/pgpull/src/xata/album_track.rs @@ -0,0 +1,8 @@ +use serde::Deserialize; + +#[derive(Debug, sqlx::FromRow, Deserialize, Clone)] +pub struct AlbumTrack { + pub xata_id: String, + pub album_id: String, + pub track_id: String, +} diff --git a/crates/pgpull/src/xata/artist.rs b/crates/pgpull/src/xata/artist.rs new file mode 100644 index 00000000..4f330455 --- /dev/null +++ b/crates/pgpull/src/xata/artist.rs @@ -0,0 +1,24 @@ +use chrono::{DateTime, Utc}; +use serde::Deserialize; + +#[derive(Debug, sqlx::FromRow, Deserialize, Clone)] +pub struct Artist { + pub xata_id: String, + pub name: String, + pub biography: Option, + #[serde(with = "chrono::serde::ts_seconds_option")] + pub born: Option>, + pub born_in: Option, + #[serde(with = "chrono::serde::ts_seconds_option")] + pub died: Option>, + pub picture: Option, + pub sha256: String, + pub spotify_link: Option, + pub tidal_link: Option, + pub youtube_link: Option, + pub apple_music_link: Option, + pub uri: Option, + pub genres: Option>, + #[serde(with = "chrono::serde::ts_seconds")] + pub xata_createdat: DateTime, +} diff --git a/crates/pgpull/src/xata/artist_album.rs b/crates/pgpull/src/xata/artist_album.rs new file mode 100644 index 00000000..89f6f1f7 --- /dev/null +++ b/crates/pgpull/src/xata/artist_album.rs @@ -0,0 +1,10 @@ +use serde::Deserialize; + +#[derive(Debug, sqlx::FromRow, Deserialize, Clone)] +pub struct ArtistAlbum { + pub xata_id: String, + pub artist_id: String, + pub album_id: String, + #[serde(with = "chrono::serde::ts_seconds")] + pub xata_createdat: chrono::DateTime, +} diff --git a/crates/pgpull/src/xata/artist_track.rs b/crates/pgpull/src/xata/artist_track.rs new file mode 100644 index 00000000..6fa911f4 --- /dev/null +++ b/crates/pgpull/src/xata/artist_track.rs @@ -0,0 +1,10 @@ +use serde::Deserialize; + +#[derive(Debug, sqlx::FromRow, Deserialize, Clone)] +pub struct ArtistTrack { + pub xata_id: String, + pub artist_id: String, + pub track_id: String, + #[serde(with = "chrono::serde::ts_seconds")] + pub xata_createdat: chrono::DateTime, +} diff --git a/crates/pgpull/src/xata/loved_track.rs b/crates/pgpull/src/xata/loved_track.rs new file mode 100644 index 00000000..4515e80f --- /dev/null +++ b/crates/pgpull/src/xata/loved_track.rs @@ -0,0 +1,10 @@ +use serde::Deserialize; + +#[derive(Debug, sqlx::FromRow, Deserialize, Clone)] +pub struct LovedTrack { + pub xata_id: String, + pub user_id: String, + pub track_id: String, + #[serde(with = "chrono::serde::ts_seconds")] + pub xata_createdat: chrono::DateTime, +} diff --git a/crates/pgpull/src/xata/mod.rs b/crates/pgpull/src/xata/mod.rs new file mode 100644 index 00000000..2c959adf --- /dev/null +++ b/crates/pgpull/src/xata/mod.rs @@ -0,0 +1,15 @@ +pub mod album; +pub mod album_track; +pub mod artist; +pub mod artist_album; +pub mod artist_track; +pub mod loved_track; +pub mod playlist; +pub mod playlist_track; +pub mod scrobble; +pub mod track; +pub mod user; +pub mod user_album; +pub mod user_artist; +pub mod user_playlist; +pub mod user_track; diff --git a/crates/pgpull/src/xata/playlist.rs b/crates/pgpull/src/xata/playlist.rs new file mode 100644 index 00000000..c9dcfc43 --- /dev/null +++ b/crates/pgpull/src/xata/playlist.rs @@ -0,0 +1,19 @@ +use chrono::{DateTime, Utc}; +use serde::Deserialize; + +#[derive(Debug, sqlx::FromRow, Deserialize, Clone)] +pub struct Playlist { + pub xata_id: String, + pub name: String, + pub description: Option, + pub picture: Option, + pub spotify_link: Option, + pub tidal_link: Option, + pub apple_music_link: Option, + #[serde(with = "chrono::serde::ts_seconds")] + pub xata_createdat: DateTime, + #[serde(with = "chrono::serde::ts_seconds")] + pub xata_updatedat: DateTime, + pub uri: Option, + pub created_by: String, +} diff --git a/crates/pgpull/src/xata/playlist_track.rs b/crates/pgpull/src/xata/playlist_track.rs new file mode 100644 index 00000000..b045a3f8 --- /dev/null +++ b/crates/pgpull/src/xata/playlist_track.rs @@ -0,0 +1,11 @@ +use serde::Deserialize; + +#[derive(Debug, sqlx::FromRow, Deserialize, Clone)] +pub struct PlaylistTrack { + pub xata_id: String, + pub playlist_id: String, + pub track_id: String, + pub added_by: String, + #[serde(with = "chrono::serde::ts_seconds")] + pub xata_createdat: chrono::DateTime, +} diff --git a/crates/pgpull/src/xata/scrobble.rs b/crates/pgpull/src/xata/scrobble.rs new file mode 100644 index 00000000..ba574762 --- /dev/null +++ b/crates/pgpull/src/xata/scrobble.rs @@ -0,0 +1,16 @@ +use chrono::{DateTime, Utc}; +use serde::Deserialize; + +#[derive(Debug, sqlx::FromRow, Deserialize, Clone)] +pub struct Scrobble { + pub xata_id: String, + pub user_id: String, + pub track_id: String, + pub album_id: Option, + pub artist_id: Option, + pub uri: Option, + #[serde(with = "chrono::serde::ts_seconds")] + pub xata_createdat: DateTime, + #[serde(with = "chrono::serde::ts_seconds")] + pub timestamp: DateTime, +} diff --git a/crates/pgpull/src/xata/track.rs b/crates/pgpull/src/xata/track.rs new file mode 100644 index 00000000..cc2b0015 --- /dev/null +++ b/crates/pgpull/src/xata/track.rs @@ -0,0 +1,31 @@ +use chrono::{DateTime, Utc}; +use serde::{Deserialize, Serialize}; + +#[derive(Debug, sqlx::FromRow, Serialize, Deserialize, Clone)] +pub struct Track { + pub xata_id: String, + pub title: String, + pub artist: String, + pub album_artist: String, + pub album_art: Option, + pub album: String, + pub track_number: i32, + pub duration: i32, + pub mb_id: Option, + pub youtube_link: Option, + pub spotify_link: Option, + pub tidal_link: Option, + pub apple_music_link: Option, + pub sha256: String, + pub lyrics: Option, + pub composer: Option, + pub genre: Option, + pub disc_number: i32, + pub copyright_message: Option, + pub label: Option, + pub uri: Option, + pub artist_uri: Option, + pub album_uri: Option, + #[serde(with = "chrono::serde::ts_seconds")] + pub xata_createdat: DateTime, +} diff --git a/crates/pgpull/src/xata/user.rs b/crates/pgpull/src/xata/user.rs new file mode 100644 index 00000000..967749a9 --- /dev/null +++ b/crates/pgpull/src/xata/user.rs @@ -0,0 +1,13 @@ +use chrono::{DateTime, Utc}; +use serde::Deserialize; + +#[derive(Debug, sqlx::FromRow, Deserialize, Clone)] +pub struct User { + pub xata_id: String, + pub display_name: String, + pub did: String, + pub handle: String, + pub avatar: String, + #[serde(with = "chrono::serde::ts_seconds")] + pub xata_createdat: DateTime, +} diff --git a/crates/pgpull/src/xata/user_album.rs b/crates/pgpull/src/xata/user_album.rs new file mode 100644 index 00000000..67bad286 --- /dev/null +++ b/crates/pgpull/src/xata/user_album.rs @@ -0,0 +1,10 @@ +use serde::Deserialize; + +#[derive(Debug, sqlx::FromRow, Deserialize, Clone)] +pub struct UserAlbum { + pub xata_id: String, + pub user_id: String, + pub album_id: String, + #[serde(with = "chrono::serde::ts_seconds")] + pub xata_createdat: chrono::DateTime, +} diff --git a/crates/pgpull/src/xata/user_artist.rs b/crates/pgpull/src/xata/user_artist.rs new file mode 100644 index 00000000..469e6a4d --- /dev/null +++ b/crates/pgpull/src/xata/user_artist.rs @@ -0,0 +1,10 @@ +use serde::Deserialize; + +#[derive(Debug, sqlx::FromRow, Deserialize, Clone)] +pub struct UserArtist { + pub xata_id: String, + pub user_id: String, + pub artist_id: String, + #[serde(with = "chrono::serde::ts_seconds")] + pub xata_createdat: chrono::DateTime, +} diff --git a/crates/pgpull/src/xata/user_playlist.rs b/crates/pgpull/src/xata/user_playlist.rs new file mode 100644 index 00000000..af8f705d --- /dev/null +++ b/crates/pgpull/src/xata/user_playlist.rs @@ -0,0 +1,10 @@ +use serde::Deserialize; + +#[derive(Debug, sqlx::FromRow, Deserialize, Clone)] +pub struct UserPlaylist { + pub xata_id: String, + pub user_id: String, + pub playlist_id: String, + #[serde(with = "chrono::serde::ts_seconds")] + pub xata_createdat: chrono::DateTime, +} diff --git a/crates/pgpull/src/xata/user_track.rs b/crates/pgpull/src/xata/user_track.rs new file mode 100644 index 00000000..0f9be606 --- /dev/null +++ b/crates/pgpull/src/xata/user_track.rs @@ -0,0 +1,10 @@ +use serde::Deserialize; + +#[derive(Debug, sqlx::FromRow, Deserialize, Clone)] +pub struct UserTrack { + pub xata_id: String, + pub user_id: String, + pub track_id: String, + #[serde(with = "chrono::serde::ts_seconds")] + pub xata_createdat: chrono::DateTime, +}