| 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 { |