mirror of
https://github.com/johrpan/musicus.git
synced 2025-10-26 19:57:25 +01:00
Add preview of main window contents
This commit is contained in:
parent
6cdaf97a36
commit
21ad91d9a9
5 changed files with 266 additions and 13 deletions
|
|
@ -137,13 +137,13 @@ impl Database {
|
|||
.cloned()
|
||||
}
|
||||
|
||||
pub fn get_work_description_for_work(&self, work: Work) -> WorkDescription {
|
||||
pub fn get_work_description_for_work(&self, work: &Work) -> WorkDescription {
|
||||
WorkDescription {
|
||||
id: work.id,
|
||||
composer: self
|
||||
.get_person(work.composer)
|
||||
.expect("Could not find composer for work!"),
|
||||
title: work.title,
|
||||
title: work.title.clone(),
|
||||
instruments: instrumentations::table
|
||||
.filter(instrumentations::work.eq(work.id))
|
||||
.load::<Instrumentation>(&self.c)
|
||||
|
|
@ -195,7 +195,7 @@ impl Database {
|
|||
|
||||
pub fn get_work_description(&self, id: i64) -> Option<WorkDescription> {
|
||||
match self.get_work(id) {
|
||||
Some(work) => Some(self.get_work_description_for_work(work)),
|
||||
Some(work) => Some(self.get_work_description_for_work(&work)),
|
||||
None => None,
|
||||
}
|
||||
}
|
||||
|
|
@ -213,6 +213,13 @@ impl Database {
|
|||
.expect("Error loading works!")
|
||||
}
|
||||
|
||||
pub fn get_work_descriptions(&self, composer_id: i64) -> Vec<WorkDescription> {
|
||||
self.get_works(composer_id)
|
||||
.iter()
|
||||
.map(|work| self.get_work_description_for_work(work))
|
||||
.collect()
|
||||
}
|
||||
|
||||
pub fn update_ensemble(&self, ensemble: Ensemble) {
|
||||
diesel::replace_into(ensembles::table)
|
||||
.values(ensemble)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue