MCPcopy Create free account
hub / github.com/Moosync/Moosync / get_song_from_queryable

Method get_song_from_queryable

src-tauri/database/src/database.rs:674–713  ·  view source on GitHub ↗
(
        &self,
        conn: &mut PooledConnection<ConnectionManager<LoggingConnection<SqliteConnection>>>,
        s: QueryableSong,
    )

Source from the content-addressed store, hash-verified

672 }
673
674 fn get_song_from_queryable(
675 &self,
676 conn: &mut PooledConnection<ConnectionManager<LoggingConnection<SqliteConnection>>>,
677 s: QueryableSong,
678 ) -> Result<Song> {
679 let mut album: Option<QueryableAlbum> = None;
680 let mut artist: Vec<QueryableArtist> = vec![];
681 let mut genre: Vec<QueryableGenre> = vec![];
682
683 let album_data =
684 QueryDsl::filter(album_bridge, schema::album_bridge::song.eq(s._id.clone()))
685 .first::<AlbumBridge>(conn);
686
687 if let Ok(album_data) = album_data {
688 album = Some(QueryDsl::filter(albums, album_id.eq(album_data.album)).first(conn)?);
689 }
690
691 let artist_data =
692 QueryDsl::filter(artist_bridge, schema::artist_bridge::song.eq(s._id.clone()))
693 .first::<ArtistBridge>(conn);
694
695 if let Ok(artist_data) = artist_data {
696 artist = QueryDsl::filter(artists, artist_id.eq(artist_data.artist)).load(conn)?;
697 }
698
699 let genre_data =
700 QueryDsl::filter(genre_bridge, schema::genre_bridge::song.eq(s._id.clone()))
701 .first::<GenreBridge>(conn);
702
703 if let Ok(genre_data) = genre_data {
704 genre = QueryDsl::filter(genres, genre_id.eq(genre_data.genre)).load(conn)?;
705 }
706
707 Ok(Song {
708 song: s,
709 album,
710 artists: Some(artist),
711 genre: Some(genre),
712 })
713 }
714
715 #[tracing::instrument(level = "debug", skip(self))]
716 pub fn get_songs_by_options(&self, options: GetSongOptions) -> Result<Vec<Song>> {

Callers 1

get_songs_by_optionsMethod · 0.80

Calls 3

cloneMethod · 0.80
eqMethod · 0.45
loadMethod · 0.45

Tested by

no test coverage detected