diff --git a/TODO.md b/TODO.md index ad3b79b..5d8e0d6 100644 --- a/TODO.md +++ b/TODO.md @@ -1,3 +1,4 @@ -- [ ] Fix major perf problems +- [x] Fix major perf problems +- [x] Stop using local threads - [ ] Read metadata into database on "import", not as needed - [ ] Add splashscreen to hide database initialization \ No newline at end of file diff --git a/src-tauri/entity/src/lib.rs b/src-tauri/entity/src/lib.rs index 80a5b87..4927598 100644 --- a/src-tauri/entity/src/lib.rs +++ b/src-tauri/entity/src/lib.rs @@ -1 +1,2 @@ -pub mod song; \ No newline at end of file +pub mod song; +pub mod metadata; \ No newline at end of file diff --git a/src-tauri/entity/src/metadata.rs b/src-tauri/entity/src/metadata.rs new file mode 100644 index 0000000..367f163 --- /dev/null +++ b/src-tauri/entity/src/metadata.rs @@ -0,0 +1,193 @@ +use sea_orm::entity::prelude::*; +use serde::{Deserialize, Serialize}; + +#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, EnumIter, DeriveActiveEnum)] +#[sea_orm(rs_type = "String", db_type = "String(StringLen::N(1))")] +pub enum ContentAdvisory { + #[sea_orm(string_value = "N")] + None, + #[sea_orm(string_value = "E")] + Explicit, + #[sea_orm(string_value = "C")] + Censored, +} + +#[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel, Serialize, Deserialize)] +#[sea_orm(table_name = "metadata")] +pub struct Model { + #[sea_orm(primary_key)] + #[serde(skip_deserializing)] + pub id: i32, + pub song_id: Option, + pub accurate_rip_count: Option, + pub accurate_rip_count_all_offsets: Option, + pub accurate_rip_count_with_offset: Option, + pub accurate_rip_crc: Option, + pub accurate_rip_disc_id: Option, + pub accurate_rip_id: Option, + pub accurate_rip_offset: Option, + pub accurate_rip_result: Option, + pub accurate_rip_total: Option, + pub acoust_id_fingerprint: Option, + pub acoust_id_id: Option, + pub album: Option, + pub album_artist: Option, + pub arranger: Option, + pub artist: Option, + pub author: Option, + pub bpm: Option, + pub cd_toc: Option, + pub comment: Option, + pub compilation_flag: Option, + pub composer: Option, + pub conductor: Option, + pub content_advisory: Option, + pub copyright: Option, + pub cue_tools_db_disc_confidence: Option, + pub cue_tools_db_track_confidence: Option, + pub date: Option, + pub description: Option, + pub disc_number: Option, + pub disc_subtitle: Option, + pub disc_total: Option, + pub encoded_by: Option, + pub encoder: Option, + pub encoder_settings: Option, + pub encoding_date: Option, + pub engineer: Option, + pub ensemble: Option, + pub genre: Option, + pub grouping: Option, + pub ident_asin: Option, + pub ident_barcode: Option, + pub ident_catalog_number: Option, + pub ident_ean_upn: Option, + pub ident_isbn: Option, + pub ident_isrc: Option, + pub ident_pn: Option, + pub ident_podcast: Option, + pub ident_upc: Option, + pub index_number: Option, + pub initial_key: Option, + pub internet_radio_name: Option, + pub internet_radio_owner: Option, + pub label: Option, + pub label_code: Option, + pub language: Option, + pub license: Option, + pub lyricist: Option, + pub lyrics: Option, + pub media_format: Option, + pub mix_dj: Option, + pub mix_engineer: Option, + pub mood: Option, + pub movement_name: Option, + pub movement_number: Option, + pub movement_total: Option, + pub mp3_gain_album_min_max: Option, + pub mp3_gain_min_max: Option, + pub mp3_gain_undo: Option, + pub music_brainz_album_artist_id: Option, + pub music_brainz_album_id: Option, + pub music_brainz_artist_id: Option, + pub music_brainz_disc_id: Option, + pub music_brainz_genre_id: Option, + pub music_brainz_label_id: Option, + pub music_brainz_original_album_id: Option, + pub music_brainz_original_artist_id: Option, + pub music_brainz_recording_id: Option, + pub music_brainz_release_group_id: Option, + pub music_brainz_release_status: Option, + pub music_brainz_release_track_id: Option, + pub music_brainz_release_type: Option, + pub music_brainz_track_id: Option, + pub music_brainz_trm_id: Option, + pub music_brainz_work_id: Option, + pub narrator: Option, + pub opus: Option, + pub original_album: Option, + pub original_artist: Option, + pub original_date: Option, + pub original_file: Option, + pub original_lyricist: Option, + pub original_writer: Option, + pub original_year: Option, + pub owner: Option, + pub part: Option, + pub part_number: Option, + pub part_total: Option, + pub performer: Option, + pub play_counter: Option, + pub podcast_category: Option, + pub podcast_description: Option, + pub podcast_flag: Option, + pub podcast_keywords: Option, + pub producer: Option, + pub production_copyright: Option, + pub purchase_date: Option, + pub rating: Option, + pub recording_date: Option, + pub recording_location: Option, + pub recording_time: Option, + pub release_country: Option, + pub release_date: Option, + pub remixer: Option, + pub replay_gain_album_gain: Option, + pub replay_gain_album_peak: Option, + pub replay_gain_album_range: Option, + pub replay_gain_reference_loudness: Option, + pub replay_gain_track_gain: Option, + pub replay_gain_track_peak: Option, + pub replay_gain_track_range: Option, + pub script: Option, + pub soloist: Option, + pub sort_album: Option, + pub sort_album_artist: Option, + pub sort_artist: Option, + pub sort_composer: Option, + pub sort_track_title: Option, + pub sort_tv_show_title: Option, + pub tagging_date: Option, + pub terms_of_use: Option, + pub track_number: Option, + pub track_subtitle: Option, + pub track_title: Option, + pub track_total: Option, + pub tv_episode: Option, + pub tv_episode_title: Option, + pub tv_network: Option, + pub tv_season: Option, + pub tv_show_title: Option, + pub url: Option, + pub url_artist: Option, + pub url_copyright: Option, + pub url_internet_radio: Option, + pub url_label: Option, + pub url_official: Option, + pub url_payment: Option, + pub url_podcast: Option, + pub url_purchase: Option, + pub url_source: Option, + pub version: Option, + pub work: Option, + pub writer: Option, +} + +#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] +pub enum Relation { + #[sea_orm( + belongs_to = "super::song::Entity", + from = "Column::SongId", + to = "super::song::Column::Id" + )] + Song, +} + +// `Related` trait has to be implemented by hand +impl Related for Entity { + fn to() -> RelationDef { + Relation::Song.def() + } +} + +impl ActiveModelBehavior for ActiveModel {} diff --git a/src-tauri/entity/src/song.rs b/src-tauri/entity/src/song.rs index 69f693a..937ca74 100644 --- a/src-tauri/entity/src/song.rs +++ b/src-tauri/entity/src/song.rs @@ -12,6 +12,16 @@ pub struct Model { } #[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] -pub enum Relation {} +pub enum Relation { + #[sea_orm(has_one = "super::metadata::Entity")] + Metadata, +} + +// `Related` trait has to be implemented by hand +impl Related for Entity { + fn to() -> RelationDef { + Relation::Metadata.def() + } +} -impl ActiveModelBehavior for ActiveModel {} \ No newline at end of file +impl ActiveModelBehavior for ActiveModel {}