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

Method get_songs_by_options

src-tauri/database/src/database.rs:716–789  ·  view source on GitHub ↗
(&self, options: GetSongOptions)

Source from the content-addressed store, hash-verified

714
715 #[tracing::instrument(level = "debug", skip(self))]
716 pub fn get_songs_by_options(&self, options: GetSongOptions) -> Result<Vec<Song>> {
717 let mut ret = vec![];
718 trace!("Getting songs by options");
719 let inclusive = options.inclusive.unwrap_or_default();
720
721 self.pool.get().unwrap().transaction(|conn| {
722 conn.transaction(|conn| {
723 let mut fetched_songs: Vec<QueryableSong> = vec![];
724
725 if let Some(song) = options.song {
726 let mut predicate = schema::allsongs::table.into_boxed();
727 predicate =
728 filter_field!(predicate, &song._id, schema::allsongs::_id, inclusive);
729 predicate = filter_field_like!(
730 predicate,
731 &song.path,
732 schema::allsongs::path,
733 inclusive
734 );
735 predicate = filter_field_like!(
736 predicate,
737 &song.title,
738 schema::allsongs::title,
739 inclusive
740 );
741 predicate = filter_field!(
742 predicate,
743 &song.sample_rate,
744 schema::allsongs::samplerate,
745 inclusive
746 );
747 predicate =
748 filter_field!(predicate, &song.hash, schema::allsongs::hash, inclusive);
749 predicate =
750 filter_field!(predicate, &song.type_, schema::allsongs::type_, inclusive);
751 predicate =
752 filter_field_like!(predicate, &song.url, schema::allsongs::url, inclusive);
753 predicate = filter_field_like!(
754 predicate,
755 &song.playback_url,
756 schema::allsongs::playbackurl,
757 inclusive
758 );
759 predicate = filter_field!(
760 predicate,
761 &song.provider_extension,
762 schema::allsongs::provider_extension,
763 inclusive
764 );
765 predicate = filter_field!(
766 predicate,
767 &song.show_in_library,
768 schema::allsongs::show_in_library,
769 inclusive
770 );
771
772 fetched_songs = predicate.load(conn)?;
773 } else if let Some(album) = options.album {

Callers 6

test_update_songFunction · 0.80
test_remove_songsFunction · 0.80
search_allMethod · 0.80
export_playlistMethod · 0.80
get_songsMethod · 0.80

Calls 7

getMethod · 0.80
get_album_songsMethod · 0.80
get_artist_songsMethod · 0.80
get_genre_songsMethod · 0.80
get_playlist_songsMethod · 0.80
loadMethod · 0.45

Tested by 3

test_update_songFunction · 0.64
test_remove_songsFunction · 0.64