mirror of
https://github.com/johrpan/musicus.git
synced 2025-10-26 19:57:25 +01:00
Initial version of new import screen
This commit is contained in:
parent
e293972c0d
commit
606ee563e9
8 changed files with 361 additions and 2 deletions
|
|
@ -167,6 +167,22 @@ impl Database {
|
|||
Ok(medium)
|
||||
}
|
||||
|
||||
/// Get mediums that have a specific source ID.
|
||||
pub fn get_mediums_by_source_id(&self, source_id: &str) -> Result<Vec<Medium>> {
|
||||
let mut mediums: Vec<Medium> = Vec::new();
|
||||
|
||||
let rows = mediums::table
|
||||
.filter(mediums::discid.nullable().eq(source_id))
|
||||
.load::<MediumRow>(&self.connection)?;
|
||||
|
||||
for row in rows {
|
||||
let medium = self.get_medium_data(row)?;
|
||||
mediums.push(medium);
|
||||
}
|
||||
|
||||
Ok(mediums)
|
||||
}
|
||||
|
||||
/// Get mediums on which this person is performing.
|
||||
pub fn get_mediums_for_person(&self, person_id: &str) -> Result<Vec<Medium>> {
|
||||
let mut mediums: Vec<Medium> = Vec::new();
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ pub enum Action {
|
|||
RecordingExists(String, Sender<Result<bool>>),
|
||||
UpdateMedium(Medium, Sender<Result<()>>),
|
||||
GetMedium(String, Sender<Result<Option<Medium>>>),
|
||||
GetMediumsBySourceId(String, Sender<Result<Vec<Medium>>>),
|
||||
GetMediumsForPerson(String, Sender<Result<Vec<Medium>>>),
|
||||
GetMediumsForEnsemble(String, Sender<Result<Vec<Medium>>>),
|
||||
DeleteMedium(String, Sender<Result<()>>),
|
||||
|
|
@ -132,6 +133,9 @@ impl DbThread {
|
|||
GetMedium(id, sender) => {
|
||||
sender.send(db.get_medium(&id)).unwrap();
|
||||
}
|
||||
GetMediumsBySourceId(id, sender) => {
|
||||
sender.send(db.get_mediums_by_source_id(&id)).unwrap();
|
||||
}
|
||||
GetMediumsForPerson(id, sender) => {
|
||||
sender.send(db.get_mediums_for_person(&id)).unwrap();
|
||||
}
|
||||
|
|
@ -346,6 +350,13 @@ impl DbThread {
|
|||
receiver.await?
|
||||
}
|
||||
|
||||
/// Get all mediums with the specified source ID.
|
||||
pub async fn get_mediums_by_source_id(&self, id: &str) -> Result<Vec<Medium>> {
|
||||
let (sender, receiver) = oneshot::channel();
|
||||
self.action_sender.send(GetMediumsBySourceId(id.to_owned(), sender))?;
|
||||
receiver.await?
|
||||
}
|
||||
|
||||
/// Get all mediums on which a person performs.
|
||||
pub async fn get_mediums_for_person(&self, id: &str) -> Result<Vec<Medium>> {
|
||||
let (sender, receiver) = oneshot::channel();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue